Sometimes you need to detect the operating system that a machine is running. This information can then be used to setup machines in different ways or to push out updates for specific operating systems. In much the same way as location can be found, the operating system can be identified.
To see a version of this script in action, please look at our "Branding your Machine with your own OEM Info" page which you can find here.
Note: Numbers in the notes correspond with the numbers down the side of the example script.
Note: There are two entries for Vista, as the version code changed in a service pack. Windows 10 used 6.4 in early previews, but this has now changed to 10.x
You will replace the second part with your own commands, which are operating system dependant.
1 ver >%systemdrive%\ver.txt 2 findstr "4.0" %systemdrive%\ver.txt
if not errorlevel 1 goto nt4
findstr "5.0" %systemdrive%\ver.txt
if not errorlevel 1 goto win2k
findstr "5.1" %systemdrive%\ver.txt
if not errorlevel 1 goto winxp
findstr "5.2" %systemdrive%\ver.txt
if not errorlevel 1 goto win2003
findstr "6000" %systemdrive%\ver.txt
if not errorlevel 1 goto vista
findstr "6001" %systemdrive%\ver.txt
if not errorlevel 1 goto vista
findstr "7600" %systemdrive%\ver.txt
if not errorlevel 1 goto win7
findstr "6.2" %systemdrive%\ver.txt
if not errorlevel 1 goto win8
findstr "6.3" %systemdrive%\ver.txt
if not errorlevel 1 goto win81
findstr "10" %systemdrive%\ver.txt
if not errorlevel 1 goto win103 goto win9x 4 goto next
:win9x
set OpSys=9x
echo %OpSys% >>%systemdrive%\result.txt
rem Windows 9x settings(enter the settings for Windows 95, 98, ME)
goto next
:nt4
set OpSys-NT4
echo %OpSys% >>%systemdrive%\result.txt
rem Windows NT4 settings(enter the settings for Windows NT 4)
goto next
:win2k
set OpSys=Win2K
echo %OpSys% >>%systemdrive%\result.txt
rem Windows 2000 settings(enter the settings for Windows 2000)
goto next
:winxp
set OpSys=XP
echo %OpSys% >>%systemdrive%\result.txt
rem Windows XP settings(enter the settings for Windows XP)
goto next
:win2003
set OpSys=Win2003
echo %OpSys% >>%systemdrive%\result.txt
rem Windows 2003 settings(enter the settings for Windows 2003 Server)
:vista
set OpSys=WinVista
echo %OpSys% >>%systemdrive%\result.txt
rem Windows Vista settings(enter the settings for Windows Vista)
:win7
set OpSys=Win7
echo %OpSys% >>%systemdrive%\result.txt
rem Windows 7 settings(enter the settings for Windows 7)
:win8
set OpSys=Win8
echo %OpSys% >>%systemdrive%\result.txt
rem Windows 7 settings(enter the settings for Windows 8)
:win81
set OpSys=Win81
echo %OpSys% >>%systemdrive%\result.txt
rem Windows 7 settings(enter the settings for Windows 8.1)
:win10
set OpSys=Win10
echo %OpSys% >>%systemdrive%\result.txt
rem Windows 7 settings(enter the settings for Windows 10)
5 :next
echo done >>%systemdrive%\result.txt
Complete Sample - Ready to Copy and Paste.
Remember to turn off word wrap when working in notepad
Top of the Page - Home Page
Last Page Update: 28/03/2015
Copyright Sembee Ltd. 1998 - 2024.
Reproduction of any content on this web site is prohibited without express written consent. Use of this web site is subject to our terms and conditions.
All trademarks and registered trademarks are property of their respective owners. This site is not endorsed or recommended by any company or organisation mentioned within and is to provide guidance only and as such we cannot be held responsible for any consequences of following the advice given.
Sembee Ltd. is registered in England and Wales at 1 Carnegie Road, Newbury, Berkshire, RG14 5DJ.
Registered company number: 4704428. VAT Number GB 904 5603 43.
Server 1