程序1(直接读取注册表版本,速度快,不过由于注册表可能被修改,可能不准确)
@echo off
for /f "tokens=6,7" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName^|find /i "ProductName"') do set os1=%%i && set os2=%%j
set VH="Home "
set VB="Business"
set VU="Ultimate"
set PR="Premium"
set BA="Basic"
if %os1% == %VH:~1,4% goto home
if %os1% == %VB:~1,8% goto business
if %os1% == %VU:~1,8% goto Ultimate
goto err
:home
if %os2% == %PR:~1,7% echo "This is Windows Vista Home Premium."
if %os2% == %BA:~1,5% echo "This is Windows Vista Home Basic."
goto end
:business
echo "This is Windows Vista Business."
goto end
:ultimate
echo "This is Windows Vista Ultimate."
goto end
:err
echo "Don't know this system."
:end
pause
程序2(通过systeminfo读取信息)
@echo off
for /f "tokens=6,7" %%i in ('systeminfo ^|find "OS 名称:"') do set os1=%%i && set os2=%%j
set VH="Home "
set VB="Business"
set VU="Ultimate"
set PR="Premium"
set BA="Basic"
if %os1% == %VH:~1,4% goto home
if %os1% == %VB:~1,8% goto business
if %os1% == %VU:~1,8% goto Ultimate
goto err
:home
if %os2% == %PR:~1,7% echo "This is Windows Vista Home Premium."
if %os2% == %BA:~1,5% echo "This is Windows Vista Home Basic."
goto end
:business
echo "This is Windows Vista Business."
goto end
:ultimate
echo "This is Windows Vista Ultimate."
goto end
:err
echo "Don't know this system."
:end
pause作者: willsion 时间: 2007-2-27 13:03 上面程序走了大弯路了。修改如下:
程序1:
@echo off
for /f "tokens=6,7" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName^|find /i "ProductName"') do set os1=%%i && set os2=%%j
if %os1% == Home goto home
if %os1% == Business goto business
if %os1% == Ultimate goto ultimate
goto err
:home
if %os2% == Premium echo "This is Windows Vista Home Premium."
if %os2% == Basic echo "This is Windows Vista Home Basic."
goto end
:business
echo "This is Windows Vista Business."
goto end
:ultimate
echo "This is Windows Vista Ultimate."
goto end
:err
echo "Don't know this system."
:end
pause
程序2:
@echo off
for /f "tokens=6,7" %%i in ('systeminfo ^|find "OS 名称:"') do set os1=%%i && set os2=%%j
if %os1% == Home goto home
if %os1% == Business goto business
if %os1% == Ultimate goto ultimate
goto err
:home
if %os2% == Premium echo "This is Windows Vista Home Premium."
if %os2% == Basic echo "This is Windows Vista Home Basic."
goto end
:business
echo "This is Windows Vista Business."
goto end
:ultimate
echo "This is Windows Vista Ultimate."
goto end