A way to determine if SP4 is installed on a remote PC with no 3rd party tool from a batch file

J

Jeff P

Hello all,

I am looking for a way to determine if SP4 for Windows 2000 is installed on
a remote PC, without any third party tool (except maybe REG.exe from NT4 Res
Kit). I am scanning for certain Hotfixes, but some of them are not required
if SP4 is on the PC.
E.g code:

:026
::*** Checks for the existence of the Registry value created by patch
MS03-026
REG QUERY "HKLM\SOFTWARE\Microsoft\Updates\Windows 2000\SP5\KB823980"
\\%SNAME%
IF ERRORLEVEL 161 GOTO :REGERROR
IF ERRORLEVEL 53 GOTO :NetError
IF ERRORLEVEL 5 GOTO :NetAccess
IF ERRORLEVEL 2 GOTO :No026
IF ERRORLEVEL 1 GOTO :error
IF ERRORLEVEL 0 GOTO :Yes026
GOTO :Error

:No026
ECHO. >> Results.log
ECHO %SNAME% is mising MS03-026 patch !!!!!!!!!!!!!!!!! >> Results.log
ECHO. >> Results.log
GOTO :SP4

:Yes026
ECHO. >> Results.log
ECHO %SNAME% has MS03-026 patch installed. >> Results.log
ECHO. >> Results.log
GOTO :SP4

:SP4
::*** Here is my problem area, not sure if this is how I should do it and if
it is how to make it work...
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CSDVersion"
\\%SNAME% >> SP.txt

IF SP4 is installed goto :End Otherwise check for another hotfix.

The SP.txt file has the following info:
Connecting to remote machine \\namf233111
REG_SZ CSDVersion Service Pack 3

Not sure if I can use that somehow for what i want to do or not?


Thanks!
 
K

Kevin Gould

C:\temp>for /f "delims=! skip=4" %a in ('reg query
"hklm\software\microsoft\wind
ows nt\currentversion" /v "csdversion"') do (echo %a
More? set VAL=%a)
csdversion REG_SZ Service Pack 1
Now get rid of everything up to and including REG_SZ
C:\temp>set VAL2=%VAL:*REG_SZ=%
C:\temp>echo %VAL2: =%
ServicePack1

Now we have irritating spaces. I've been unsuccessful in replacing just
spaces, so here's a vicious hack where I replace everything UP to and
including the S with an S

set VAL2=%VAL2:*S=S%

now
if /i "%VAL2%"=="Service Pack 1" echo It's a number one!!
 
Top