:: Name : Detect Operating System :: Purpose : Template for detecting Windows versions :: Submitter: Slobodan Vujnovic, updated by Ben Kent :: Modified : 27 Mar 2004 :: Requires : Nothing VER | FIND /i "NT" >NUL IF NOT ERRORLEVEL 1 GOTO WNT VER | FIND /i "Windows 2000" >NUL IF NOT ERRORLEVEL 1 GOTO W2K VER | FIND /i "Windows XP" >NUL IF NOT ERRORLEVEL 1 GOTO WXP VER | FIND /i "[Version 5.2." IF NOT ERRORLEVEL 1 GOTO W2K3 VER | FIND /i "Windows 95" >NUL IF NOT ERRORLEVEL 1 GOTO W95 VER | FIND /i "Windows 98" >NUL IF NOT ERRORLEVEL 1 GOTO W98 VER | FIND /i "Windows Millennium" >NUL IF NOT ERRORLEVEL 1 GOTO WME GOTO Unknown :: ------------------------------------ :WNT echo Windows NT GOTO GotOS :: ------------------------------------ :W2K echo Windows 2000 REM This is slow, but allows the variants of Windows 2000 to be detected start /wait msinfo32 /categories "+SystemSummary" /report %temp%\msd.txt type %temp%\msd.txt | findstr /B /c:"OS Name">%temp%\~OSType.tmp type %temp%\~OSType.tmp | find /i "advanced" >nul IF NOT ERRORLEVEL 1 GOTO W2K_Adv type %temp%\~OSType.tmp | find /i "datacenter" >nul IF NOT ERRORLEVEL 1 GOTO W2K_Data type %temp%\~OSType.tmp | find /i "server" >nul IF NOT ERRORLEVEL 1 GOTO W2K_Svr type %temp%\~OSType.tmp | find /i "professional" >nul IF NOT ERRORLEVEL 1 GOTO W2K_Wks Echo Unknown 2000 subtype type %temp%\~OSType.tmp GOTO GotOS :W2K_Adv Echo Advanced Server GOTO GotOS :W2K_Data Echo Datacenter server GOTO GotOS :W2K_Svr Echo Server GOTO GotOS :W2K_Wks Echo Workstation GOTO GotOS :: ------------------------------------ :WXP echo Windows XP REM This is slow, but allows the variants of Windows XP to be detected start /wait msinfo32 /categories SystemSummary /report %temp%\msd.txt type %temp%\msd.txt | findstr /B /c:"OS Name">%temp%\~OSType.tmp type %temp%\~OSType.tmp | find /i "professional" >nul IF NOT ERRORLEVEL 1 GOTO WXP_Pro type %temp%\~OSType.tmp | find /i "home" >nul IF NOT ERRORLEVEL 1 GOTO WXP_Home type %temp%\~OSType.tmp | find /i "media" >nul IF NOT ERRORLEVEL 1 GOTO WXP_Media Echo Unknown XP subtype type %temp%\~OSType.tmp GOTO GotOS :WXP_Pro Echo Professional GOTO GotOS :WXP_Home Echo Home GOTO GotOS :WXP_Media Echo Media Centre GOTO GotOS :: ------------------------------------ :W2K3 echo Windows 2003 REM This is slow, but allows the variants of Windows 2003 to be detected start /wait msinfo32 /categories SystemSummary /report %temp%\msd.txt type %temp%\msd.txt | findstr /B /c:"OS Name">%temp%\~OSType.tmp type %temp%\~OSType.tmp | find /i "datacenter" >nul IF NOT ERRORLEVEL 1 GOTO W2K3_Data type %temp%\~OSType.tmp | find /i "enterprise" >nul IF NOT ERRORLEVEL 1 GOTO W2K3_Ent type %temp%\~OSType.tmp | find /i "standard" >nul IF NOT ERRORLEVEL 1 GOTO W2K3_Std type %temp%\~OSType.tmp | find /i "web" >nul IF NOT ERRORLEVEL 1 GOTO W2K3_Web Echo Unknown 2003 server subtype type %temp%\~OSType.tmp GOTO GotOS :W2K3_Data Echo Datacenter server GOTO GotOS :W2K3_Ent Echo Enterprise Server GOTO GotOS :W2K3_Svr Echo Standard Server GOTO GotOS :W2K3_Wks Echo Web server GOTO GotOS :: ------------------------------------ :W95 echo Windows 95 GOTO GotOS :W98 echo Windows 98 GOTO GotOS :WME echo Windows ME GOTO GotOS :: ------------------------------------ :Unknown echo Unknown Windows version VER :GotOS Pause