Skip navigation

JSI Tip 2405. How do determine the Windows NT / Windows 2000 O/S type in a logon script?


Use gettype from the

gettype \[\\RemoteComputer\] \[/s\]

Where: \\RemoteComputer specifies an optional remote computer on which to run GetType.

/s specifies silent mode.

GetType will run on any 32-bit client and sets the error level (%ERRORLEVEL%) as follows:

Error level Meaning
1   Windows NT Workstation
2   Windows 2000 Professional
3   Windows NT Server Non-Domain Controller
4   Windows 2000 Server Non-Domain Controller
5   Windows NT Server Domain Controller
6   Windows 2000 Server Domain Controller
7   Windows NT \[Enterprise/Terminal\] Server Domain Controller
8   Windows NT \[Enterprise/Terminal\] Server Non-Domain Controller

Here is a code snipit you can include in your logon script:

set ERRORLEVEL= 
if "%OS%"=="Windows_NT" goto WINNT 
set ERRORLEVEL=9 
goto ERRL 
:WINNT 
%LogonServer%\netlogon\gettype.exe 
:ERRL 
set NTNUM=%ERRORLEVEL% 
goto T%ERRORLEVEL% 
:T9
SET NTTYPE="Unknown" 
goto END 
:T8
SET NTTYPE="Windows NT \[Enterprise/Terminal\] Server Non-Domain Controller" 
goto END 
:T7
SET NTTYPE="Windows NT \[Enterprise/Terminal\] Server Domain Controller" 
goto END 
:T6 
SET NTTYPE="Windows 2000 Server Domain Controller" 
goto END 
:T5 
SET NTTYPE="Windows NT Server Domain Controller" 
goto END 
:T4 
SET NTTYPE="Windows 2000 Server Non-Domain Controller" 
goto END 
:T3 
SET NTTYPE="Windows NT Server Non-Domain Controller" 
goto END 
:T2 
SET NTTYPE="Windows 2000 Professional" 
goto END 
:T1 
SET NTTYPE="Windows NT Workstation" 
:END
The script returns two environment variables, NTNUM (%ERRORLEVEL%) and NTTYPE which you can use.


Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish