如何修复文件的goto部分以获取操作系统的版本和类型



这个脚本问题已经在用户sachadee的帮助下得到了解答。所以特别感谢他,所以你所要做的就是复制并粘贴到记事本或其他文本编辑器中,并保存为。bat文件,并在不同的部分添加你的代码。

@echo
setlocal EnableDelayedExpansion
::Identify OS
for /F "delims=" %%a in ('ver') do set ver=%%a
set Version=
for %%a in (95=95 98=98 ME=ME NT=NT 2000=2000 5.1.=XP 5.2.=2003 6.0.=Vista 6.1.=7 6.2.=8 6.3.=8.1) do (
if "!Version!" equ "this" (
  set Version=Windows %%a
  ) else if "!ver: %%a=!" neq "%ver%" (
  set Version=this
 )
)
::Identify bit
if exist "%SYSTEMDRIVE%Program Files (x86)" (
set Type=64 bit
) else (
set Type=32 bit
)
::Display result
echo %Version% %Type%
:: This code matches it to the correct section below based on what version and type
:: of OS your running
if /I "%Version% %Type%"=="Windows 2000" ( goto :ver_2000 )
if /I "%Version% %Type%"=="Windows XP 32 bit" ( goto :ver_XP )
if /I "%Version% %Type%"=="Windows XP 64 bit" ( goto :ver_XP_x64 )
if /I "%Version% %Type%"=="Windows Vista 32 bit" ( goto :ver_Vista )
if /I "%Version% %Type%"=="Windows Vista 64 bit" ( goto :ver_Vista_x64 )
if /I "%Version% %Type%"=="Windows 7 32 bit" ( goto :ver_7 )
if /I "%Version% %Type%"=="Windows 7 64 bit" ( goto :ver_7_x64 )
if /I "%Version% %Type%"=="Windows 8 32 bit" ( goto :ver_8 )
if /I "%Version% %Type%"=="Windows 8 64 bit" ( goto :ver_8_x64 )
if /I "%Version% %Type%"=="Windows 8.1 32 bit" ( goto :ver_8.1 )
if /I "%Version% %Type%"=="Windows 8.1 64 bit" ( goto :ver_8.1_x64 )

:: runs program or script depending on windows version ::
:ver_2000
:Run Windows 2000 specific commands here.
echo Windows 2000
pause
your code goes here
goto exit
:ver_XP
:Run Windows XP specific commands here.
echo Windows XP 32bit
pause
your code goes here
goto exit
:ver_XP_x64
:Run Windows XP 64bit specific commands here.
echo Windows XP 64bit
pause
your code goes here
goto exit
:ver_Vista
:Run Windows Vista specific commands here.
echo Windows Vista 32bit
pause
your code goes here
goto exit
:ver_Vista_x64
:Run Windows Vista 64bit specific commands here.
echo Windows Vista 64bit
pause
your code goes here
goto exit
:ver_7
:Run Windows 7 specific commands here.
echo Windows 7 32bit
pause
your code goes here
goto exit
:ver_7_x64
:Run Windows 7 64bit specific commands here.
echo Windows 7 64bit
pause
your code goes here
goto exit
:ver_2008
:Run Windows Server 2008 specific commands here.
echo Windows Server 2008 32bit
pause
your code goes here
goto exit
:ver_2008_x64
:Run Windows Server 2008 64bit specific commands here.
echo Windows Server 2008 64bit
pause
your code goes here
goto exit
:ver_8
:Run Windows 8 specific commands here.
echo Windows 8 32bit
pause
your code goes here
goto exit
:ver_8_x64
:Run Windows 8 64bit specific commands here.
echo Windows 8 64bit
pause
your code goes here
goto exit
:ver_8.1
:Run Windows 8 specific commands here.
echo Windows 8.1 32bit
pause
your code goes here
goto exit
:ver_8.1_x64
:Run Windows 8.1 64bit specific commands here.
echo Windows 8.1 64bit
pause
your code goes here
goto exit
:exit

试试:

if /I "%Version% %Type%"="windows 8.1 64 bit" goto:ver_8_x64

相关内容

  • 没有找到相关文章

最新更新