|
Broadband - Exchange Login Scripts - Net Admin Outlook - Windows Mobile Windows
Contact - Advertise

Login Scripts
Getting Started
Creating the Initial File
Testing
Implementation
Basic Techniques
Mapping Network Drives
Connecting Printers
Section Labels
More Advanced Techniques
Domain Group Membership For Drive and Printer Mapping
Recording Script Results
Location Detection
Machine Identification
Operating System Detection
Limiting the Number of Logins
Registry Changes
Redirection of Internet Explorer Favourites
Checking for Existence of a File or Directory
|
Operating System Detection
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.
- First, collect the version information and dump it to a file. In this case we are using the system drive variable to set the location. This will usually be "c:\"
- The "findstr" command then searches the "ver.txt" file for the number which coincides with the version of Windows the script is running on. When it gets a match, it moves on to the indicated section. Otherwise it carries on down the list.
- If it fails then the script presumes it is a variant of Windows 9x (95, 98 or ME) and send it to that point in the script.
- Now for each operating system, the script does two things, before moving on to the "next" section.
- It creates a new variable called "OpSys" with a small label that identifies the operating system. This could be used later in the script if required.
- In this example login script, "echo" is used to append the new variable to a file called "result.txt" which will be found in the system drive (c:\ usually). This allows you to check whether the script is working correctly.
You will replace the second part with your own commands, which are operating system dependant.
- The ":next" section could be any part of your login script.
In this example it appends "done" to the "result.txt" file created earlier in the script.
| 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 |
| 3 |
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) |
| 5 |
:next echo done >>%systemdrive%\result.txt |
Complete Sample - Ready to Copy and Paste.
Remember to turn off word wrap when working in notepad
|