Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 变量中的Windows 9x/Me版本_Batch File_Variables_Windows 98_Windows 95 - Fatal编程技术网

Batch file 变量中的Windows 9x/Me版本

Batch file 变量中的Windows 9x/Me版本,batch-file,variables,windows-98,windows-95,Batch File,Variables,Windows 98,Windows 95,如何将Windows 9x/Me版本存储到变量中?我不知道Windows 95、Windows 98和Windows Millennium的COMMAND.COM是否支持将命令的输出分配给环境变量。我在运行Windows 98 SE的机器上测试的明确支持是: @echo off set WinVer=unknown rem Windows 95 ver | find "4.00.950" >nul if not errorlevel 1 set WinVer=4.00

如何将Windows 9x/Me版本存储到变量中?

我不知道Windows 95、Windows 98和Windows Millennium的
COMMAND.COM
是否支持将命令的输出分配给环境变量。我在运行Windows 98 SE的机器上测试的明确支持是:

@echo off
set WinVer=unknown

rem Windows 95
ver | find "4.00.950" >nul
if not errorlevel 1 set WinVer=4.00.950

rem Windows 95 SR2
ver | find "4.00.1111" >nul
if not errorlevel 1 set WinVer=4.00.1111

rem Windows 98
ver | find "4.10.1998" >nul
if not errorlevel 1 set WinVer=4.10.1998

rem Windows 98 SE
ver | find "4.10.2222" >nul
if not errorlevel 1 set WinVer=4.10.2222

rem Windows Millennium
ver | find "4.90.3000" >nul
if not errorlevel 1 set WinVer=4.90.3000

echo Windows version is: %WinVer%
对于该任务来说,最好使用如下批处理文件:

@echo off
ver | find "4.00." >nul
if not errorlevel 1 goto Win95
ver | find "4.10." >nul
if not errorlevel 1 goto Win98
ver | find "4.90." >nul
if not errorlevel 1 goto WinMe

echo ERROR: Could not determine Windows version!
goto EndBatch

:Win95
echo INFO: Detected OS as Windows 95.
rem More commands to run for Windows 95.
goto EndBatch

:Win98
echo INFO: Detected OS as Windows 98.
rem More commands to run for Windows 98.
goto EndBatch

:WinMe
echo INFO: Detected OS as Windows ME.
rem More commands to run for Windows ME.
goto EndBatch

rem Commands for other versions of Windows.

:EndBatch
请注意不要使用超过八个字符的标签。可以使用更长的标签名称,但对于
COMMAND.COM
而言,只有前八个字符有效,即
goto Windows98
将被解释为
goto Windows9
,因此批处理文件将在标签下方的行上继续执行,从
Windows9
开始


此处使用的Windows版本字符串取自Wikipedia文章。

我希望Windows版本号与Windows 7版本6.1.7601相同(我希望Windows 9X版本包含在变量中。Windows 7只是一个示例)。我想检查版本,以便在您使用Windows 95时,使用98/Me更简单的代码关闭计算机,使用Windows 95代码关闭计算机。