Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logon Scripts 2

Status
Not open for further replies.

drcab

Programmer
Nov 16, 2000
32
0
0
US
In order to push a recent patch from Microsoft I need to determine what OS a workstation is running within a logon type script prior to running the patch. What is the cmd line to determine what OS the box is running? From there I can do a If Then... Any Help is appreciated.
 
Use the "ver" command to detemrine the OS.

For example:

ver | find /i "2000"
if errorlevel 1 goto check2
if errorlevel 0 goto 2kpatch
:2kpatch
2kpatch.exe -q -u -z
goto end
:check2
ver | find /i "4.0"
if errorlevel 1 goto check3
if errorlevel 0 goto ntpatch
:ntpatch
ntpatch.exe -q -u -z
goto end
:check3
ver | find /i "xp"
if errorlevel 1 goto end
if errorlevel 0 goto xppatch
:xppatch
xppatch.exe -q -u -z
:end

This of course assumes the user logging in has local admin rights, or the patches won't get too far.

 
HI.

There are several methods.
Here is one of them:

ver | find "XP"
if errorlevel 1 goto skip
REM XP
:skip

Or this:
ver | find "XP"
if not errorlevel 1 ....

You can also query some registry keys using VBScript or other tools.
Here is a sample VBS file (if you don't have Win9x workstations, you can make it simplier):

set oshell = wscript.createobject("wscript.shell")
on error resume next
winver = oshell.regread("HKLM\Software\Microsoft\Windows\CurrentVersion\ProductName")
if err then
winver = oshell.regread("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName")
end if
iever = oshell.regread("HKLM\SOFTWARE\Microsoft\Internet Explorer\Version")
wscript.echo winver + "," + iever

More info here:



Yizhar Hurwitz
 
Great! That worked. I only have 2k and NT machines on my network so it should be easy enough, I appreciate the assistance.
Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top