Skip navigation

JSI Tip 4400. How do I determine the operating system version in a logon script?

Now that Windows NT has many versions (NT 3.5x, NT 4.0, NT 5.0 (Windows 2000), and NT 5.1 (Windows XP)),
how do I determine which version my client is running, in a logon script?

If you only have NT 4.0 and NT 5.0, you could use tip 2405.

For a more enduring solution, I have scripted NTV.BAT, which returns an environment variable, NTV, containing the version number.

To use the script:

1. Copy NTV.BAT to the Netlogon share (an replicas).

2. Copy RegFree.exe to the Netlogon share.

3. If you have any Windows 9x or Windows ME clients, you may want to implement tip 1786.

4. In your logon script:

set NTV=N/A
if "%OS%"

"Windows_NT" call %logonserver%\netlogon\NTV.BAT

NOTE: See tip 4401 for an alternate script that does NOT use RegFree.

You can then test the NTV environment variable. Here is sample:

if "%NTV%""N/A" goto Win9x
if "%NTV%"

"4.0" goto WNT if "%NTV%"

"5.0" goto W2K REM Windows XP here
NTV.BAT contains:
@echo off
set NTV=N/A
if NOT "%OS%"=="Windows_NT" goto :EOF
for /f "Tokens=*" %%i in ('%LOGONSERVER%\Netlogon\regfree -Quiet -ListValue "hklm\Software\Microsoft\Windows NT\CurrentVersion\CurrentVersion"') do set NTV="%%i"
set NTV=%NTV:REG_SZ =%
set NTV=%NTV:"=%

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