amset

.info
.co.uk - exchange consultancy
.net - internet based solutions

Broadband - Exchange
Login Scripts - Net Admin
Outlook - Windows Mobile
Windows

Contact - Advertise

AddThis Social Bookmark Button

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.

  1. 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:\"
  2. 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.
  3. 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.
  4. Now for each operating system, the script does two things, before moving on to the "next" section.
    1. 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.
    2. 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.

  5. 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

Sponsored Links

Last Page Update:
18/02/2008

Back to the Top
Contact Us - Advertise on amset.info
Login Scripts Index - Home Page


Broadband - Exchange - Login Scripts - Network Admin - Outlook - Windows Mobile - Windows


© Amset IT Solutions Ltd. 1998 - 2008. All rights reserved. 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 on this site. This site is to provide guidance only and as such we cannot be held responsible for any consequences of following the advice given.