How to determine the OS type in a logon script

This article was previously published under Q190899
This article has been archived. It is offered "as is" and will no longer be updated.
Often, administrators would like to run software on only their Windows 95 or Windows 98 clients, or their Windows NT Workstation clients. They may not want to run some logon script commands on their Windows NT Server computers or domain controllers.
Using a simple batch file and a small executable file, you can tell if theclient is a:
  • Windows 95 or Windows 98 client
  • Windows NT workstation
  • Windows 2000 Professional installation
  • Windows NT Server non-domain controller
  • Windows 2000 Server non-domain controller
  • Windows NT Server domain controller
  • Windows 2000 Server domain controller
  • Windows NT Enterprise/Terminal Server domain controller
  • Windows NT Enterprise/Terminal Server non-domain controller
Copy the following text to a batch file:
@echo offREM Batch file to detect OSREM ----------------------------------if Windows_NT == %OS% goto WINNTecho You are not running Windows NT (Windows 95/98 perhaps?)goto END:WINNTgettype.exeif errorlevel=9 goto FILENOTFOUNDecho You are running Windows NT.echo More Specifically:echo.if ERRORLEVEL=8 goto EIGHTif ERRORLEVEL=7 goto SEVENif ERRORLEVEL=6 goto SIXif ERRORLEVEL=5 goto FIVEif ERRORLEVEL=4 goto FOURif ERRORLEVEL=3 goto THREEif ERRORLEVEL=2 goto TWOif ERRORLEVEL=1 goto ONE:FILENOTFOUNDecho.echo Gettype not found.echo.goto END:EIGHTecho Windows NT Enterprise/Terminal Server Non-Domain Controllergoto END:SEVENecho Windows NT Enterprise/Terminal Server Domain Controllergoto END:SIXecho Windows 2000 Server Domain Controllergoto END:FIVEecho Windows NT Server Domain Controllergoto END:FOURecho Windows 2000 Server Non-Domain Controllergoto END:THREEecho Windows NT Server Non-Domain Controllergoto END:TWOecho Windows 2000 Professional installationgoto END:ONEecho Windows NT Workstationgoto END:ENDpause				
Copy the Gettype.exe file and the batch file to the target workstations and run the batch file.

You can obtain Gettype.exe version 4.0 by installing the Windows 2000 Resource Kit Tools.
Gettype.exe works by querying the registry for the installation type and setting the DOS ERRORLEVEL appropriately:
  • Returns 1 for Windows NT Workstation.
  • Returns 2 for Windows 2000 Professional.
  • Returns 3 for Windows NT Server non-domain controller.
  • Returns 4 for Windows 2000 Server non-domain controller.
  • Returns 5 for Windows NT Server domain controller.
  • Returns 6 for Windows 2000 Server domain controller.
  • Returns 7 for Windows NT Enterprise/Terminal Server domain controller.
  • Returns 8 for Windows NT Enterprise/Terminal Server non-domain controller.
Silent mode can be set with the /s parameter. This tool can also be run against remote computers.
batch file logon script login

Article ID: 190899 - Last Review: 12/05/2015 09:04:45 - Revision: 5.3

Microsoft Windows 2000 Advanced Server, Microsoft Windows 2000 Professional Edition, Microsoft Windows 2000 Server, Microsoft Windows NT Server 4.0, Terminal Server Edition, Microsoft Windows NT Server 3.51, Microsoft Windows NT Server 4.0 Standard Edition, Microsoft Windows NT Workstation 3.51, Microsoft Windows NT Workstation 4.0 Developer Edition, Microsoft Windows NT Server 4.0 Enterprise Edition, Microsoft Windows 98 Standard Edition, Microsoft Windows 95

  • kbnosurvey kbarchive kbenv kbhowto KB190899