Board logo

标题: 求教:如何判断当前操作系统是否为 WIN2000 [打印本页]

作者: maxfull     时间: 2007-6-20 15:54    标题: 求教:如何判断当前操作系统是否为 WIN2000

求教:如何判断当前操作系统是否为 WIN2000 如果是WINDOWS2000则执行2K.BAT,如果非WINDOWS2000,如XP或2003则执行XP.BAT..谢谢.

请不要使用判断WINNT目录,因为这样的准确性不高.最好是以内核来判断.
作者: zasxcdfv     时间: 2007-6-20 16:06
用ver命令
作者: oilio     时间: 2007-6-20 16:17
我写的批处理比较糙,大家可千万不要笑话我啊,各位朋友帮我完善一下。这个是判断系统是否为xp,如果是的话,就运行D盘下的1.txt文件,我在我机器上测试成功了。不过可惜的是我好像记得wmic是2003和xp下才有吧,不知道2000下有没有。
@echo off
for /f "skip=1 tokens=3" %%a in ('wmic os get caption') do (
if /i "%%a"=="xp" start "" "d:\1.txt"
)
pause
[ Last edited by oilio on 2007-6-20 at 04:21 PM ]
作者: zh159     时间: 2007-6-20 16:30
ver|find "Windows XP">nul&&echo XP||echo 2K

自己根据2000的提示修改
作者: joshualaw     时间: 2007-6-20 21:29


  Quote:
Originally posted by oilio at 2007-6-20 04:17 PM:
我写的批处理比较糙,大家可千万不要笑话我啊,各位朋友帮我完善一下。这个是判断系统是否为xp,如果是的话,就运行D盘下的1.txt文件,我在我机 ...

在WIN2K下无wmic,在那可得到
作者: joshualaw     时间: 2007-6-22 07:34


  Quote:
Originally posted by joshualaw at 2007-6-20 09:29 PM:


在WIN2K下无wmic,在那可得到

在XP 也下无wmic,在那可得到
作者: zh159     时间: 2007-6-22 09:19


  Quote:
Originally posted by joshualaw at 2007-6-22 07:34:

在XP 也下无wmic,在那可得到

你的XP是简化版的吧?
作者: HAT     时间: 2007-6-22 10:10
//在XP 也下无wmic,在那可得到

简化版的XP还是少用为好

  Quote:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\>wmic /?
[global switches] <command>

The following global switches are available:
/NAMESPACE           Path for the namespace the alias operate against.
/ROLE                Path for the role containing the alias definitions.
/NODE                Servers the alias will operate against.
/IMPLEVEL            Client impersonation level.
/AUTHLEVEL           Client authentication level.
/LOCALE              Language id the client should use.
/PRIVILEGES          Enable or disable all privileges.
/TRACE               Outputs debugging information to stderr.
/RECORD              Logs all input commands and output.
/INTERACTIVE         Sets or resets the interactive mode.
/FAILFAST            Sets or resets the FailFast mode.
/USER                User to be used during the session.
/PASSWORD            Password to be used for session login.
/OUTPUT              Specifies the mode for output redirection.
/APPEND              Specifies the mode for output redirection.
/AGGREGATE           Sets or resets aggregate mode.
/AUTHORITY           Specifies the <authority type> for the connection.
/?[:<BRIEF|FULL>]    Usage information.

For more information on a specific global switch, type: switch-name /?