HOWTO: Determining The OS Type In A Logon Script

ID: Q190899

The information in this article applies to:

SUMMARY

Often administrators would like to run software on only their Windows 95 or 98 clients or their Windows NT Workstation clients. They do not want to run some logon script commands on their Windows NT Server computers or domain controllers.

MORE INFORMATION

Using a simple batch file and a small executable file, you can tell if the client is a:

Copy the following to a batch file:

   95_or_nt.bat
   ============

   @echo off
   if Windows_NT == %OS% goto WINNT
   echo You are NOT running Windows NT
   goto END

   :WINNT
   gettype
   echo You are running Windows NT.
   echo More Specifically:
   echo.

   if ERRORLEVEL=5 goto FIVE
   if ERRORLEVEL=4 goto FOUR
   if ERRORLEVEL=3 goto THREE
   if ERRORLEVEL=2 goto TWO
   if ERRORLEVEL=1 goto ONE

   :FIVE
   echo Windows NT [Enterprise/Terminal] Server Domain Controller
   goto END

   :FOUR
   echo Windows NT [Enterprise/Terminal] Server Non-Domain Controller
   goto END

   :THREE
   echo Windows NT Server Domain Controller
   goto END

   :TWO
   echo Windows NT Server Non-Domain Controller
   goto END

   :ONE
   echo Windows NT Workstation
   goto END

   :END
   pause

   ==============
   end batch file

The executable, GetType.exe version 2.0, can be obtained from Microsoft Product Support Services.

The executable works by querying the registry for the install type and setting the DOS ERRORLEVEL appropriately:

   5 = Windows NT [Enterprise/Terminal] Server Domain Controller
   4 = Windows NT [Enterprise/Terminal] Server Non-Domain Controller
   3 = Windows NT Server Domain Controller
   2 = Windows NT Server Non-Domain Controller
   1 = Windows NT Workstation

Silent mode can be set with the /s parameter. This tool can also be run against remote computers.

Additional query words: batch file logon script login

Version           : Windows:95,98;WinNT:3.51,4.0
Platform          : WINDOWS winnt
Issue type        : kbhowto

Last Reviewed: November 25, 1998