將系統(tǒng)環(huán)境變量 %ERRORLEVEL% 設(shè)置為與指定的
gettype [/s Computer [/u
Gettype 查詢href="HELP=glossary.hlp TOPIC=gls_registry">注冊(cè)表中的安裝類型并將錯(cuò)誤值設(shè)置為下表中描述的值,以此來確定操作系統(tǒng)類型。
ERRORLEVEL | 描述 |
---|---|
1 | |
2 | |
3 | |
4 | |
5 | |
6 |
Gettype 查詢href="HELP=glossary.hlp TOPIC=gls_registry">注冊(cè)表中的安裝類型并將錯(cuò)誤值設(shè)置為下表中描述的值,以此來確定操作系統(tǒng)角色。
ERRORLEVEL | 描述 |
---|---|
1 | 域控制器 |
2 | 成員服務(wù)器 |
3 | 工作組 |
通過在批處理文件中使用 gettype,可以創(chuàng)建只在檢測到特定的平臺(tái)時(shí)才運(yùn)行的腳本。例如,如果您正在運(yùn)行 Windows NT,則下列批處理文件檢測操作系統(tǒng)類型。如果您未運(yùn)行 Windows NT,則它將退出腳本。
@echo off
REM 批處理文件以檢測操作系統(tǒng)
REM ----------------------------------
if Windows_NT == %OS% goto WINNT
echo You are NOT running Windows NT (Windows 95/98 perhaps?)
goto END
:WINNT
gettype.exe
if errorlevel=255 goto FILENOTFOUND
echo You are running Windows NT.
echo More Specifically:
echo
if ERRORLEVEL=5 goto FIVE
if ERRORLEVEL=4 goto FOUR
if ERRORLEVEL=3 goto THREE
if ERRORLEVEL=2 goto TWO
if ERRORLEVEL=1 goto ONE
:FILENOTFOUND
echo
echo Gettype not found.
echo
goto END
:FIVE
echo Windows Server 2003 Datacenter Edition .
goto END
:FOUR
echo Windows Server 2003 Enterprise Edition .
goto END
:THREE
echo Windows Server 2003 Standard Edition .
goto END
:TWO
echo Windows XP Professional .
goto END
:ONE
echo Windows XP Home Edition .
goto END
:END
pause
格式 | 含義 |
---|---|
斜體 | 用戶必須提供的信息 |
粗體 | 用戶必須準(zhǔn)確鍵入的要顯示的元素 |
省略號(hào) (...) | 在命令行中可多次重復(fù)的參數(shù) |
中括號(hào) ([]) | 可選項(xiàng) |
大括號(hào) ({});選項(xiàng)用豎線 (|) 分隔。例如:{even|odd} | 用戶必須從選項(xiàng)集合中選擇一個(gè) |
Courier 字體 | 代碼或程序輸出 |