JSI Tip 4401. Another way to set the Operating system version number in a logon script.

In a tip 4400, I scripted NTV.BAT to return an NTV environment variable contains the operating system version number.

I have scripted another version of NTV.BAT that does not use any add-on software.

To use the new NTV.BAT:

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

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

3. In your logon script:

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

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

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 downlev
regedit /a %TEMP%\CV.REG "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion"
@echo "CurrentVersion"=>%TEMP%\CVS.TXT
for /f "Tokens=*" %%i in ('findstr /b /g:%TEMP%\CVS.TXT %TEMP%\CV.REG') do set line="%%i"&call :parse
del /q %TEMP%\CV.REG
del /q %TEMP%\CVS.TXT
endlocal&set NTV=%NTV%
goto :EOF
set work=%line:"=%
set work=%work:CurrentVersion=%
set NTV=%work:~1,9%

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.