[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1042
  • Last Modified:

Batch with reg Query for XP SP1 installed

I am trying to create batch file with Reg Query that will tell me if XP Service Pack 1 is installed
can some one assist me please

Thanks!!
Echo off
cls
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\BuildLab\2600.xpsp2.030422-1633"
if errorlevel 1 goto UnohaveSP1
if errorlevel 0 goto UhaveSP1
:UnohaveSP1
echo :-(
goto end
:UhaveSP1
echo :-D hurray!!!!!!!!!!!!!!!!
goto end
:end
pause
0
lf_lake
Asked:
lf_lake
  • 5
  • 4
  • 3
  • +1
1 Solution
 
sramesh2kCommented:
Hi,

See if the WMI script helps:

Identifying the Latest Installed Service Pack:
http://www.microsoft.com/resources/documentation/windows/2000/server/scriptguide/en-us/sas_cpm_tscm.mspx
0
 
DrWarezzCommented:
You're just about there, try this:


:----8<------------------------------ FileName.bat --------------------------------------:
@ECHO OFF
CLS
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\BuildLab\2600.xpsp2.030422-1633"
set err=%errorlevel%

if %err%==0 goto :UHAVESP1
if %err%==1 goto :UNOHAVESP1

:DEFAULT
echo An error occured. The returned errorlevel is: %err% & goto :EOF

:UNOHAVESP1
echo You do not have SP1 installed. & goto :EOF

:UHAVESP1
echo You have SP1 installed. & goto :EOF

:EOF
echo.
echo [Press any key to exit ...]
pause >>NUL
exit
:----8<------------------------------ FileName.bat --------------------------------------:

Good luck!
[r.D]
0
 
kapesCommented:
if u can run vbscript then, u won't to rely on reg.exe to be present on all machines...

try this


---------------- CheckSP1.vbs ------------------------------------
Dim RegPath, oWshShell, RegValue

RegPath = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\BuildLab\2600.xpsp2.030422-1633"

On Error Resume Next
Set oWshShell = CreateObject ("WScript.Shell")

RegValue = oWshShell.RegRead (RegPath)

If Err Then
'oWshShell.Popup "Error Accessing registry key (" & Err.Number & ") : " & Err.Description,0,"Check XP SP 1",vbCritical
oWshShell.Popup ":-( , XP SP1 is NOT installed",0,"Check XP SP 1",vbCritical
Err.Clear
Else
oWshShell.Popup "Registry path exists, so XP SP 1 is installed !!",0,"Check XP SP 1",vbInformation
End If

----------------------------------------------------------------




0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
lf_lakeAuthor Commented:
Unfortunately, neither of thes work ... the batch file runs straight the and shows no messages ... the vb script show XP SP1 as not being installed

0
 
DrWarezzCommented:
Very strange -- have you tried sramesh2k's idea?

[r.D]
0
 
kapesCommented:
r u sure... u r checking the right key for existence of SP1 ?

0
 
lf_lakeAuthor Commented:
This is the key in my registry where the "2600.xpsp2.030422-1633" appears
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion
there is a string word value called "BuildLab" which has the data value of  "2600.xpsp2.030422-1633"

my apologies if this is not correct, however this is the value I am seeing.  If this is not the correct key to query kindly advise

Kind Regards
0
 
DrWarezzCommented:
Going by the data: 2600.xpsp2.030422-1633, that's actually created if SP2 is installed, and NOT SP1..

Also, you say that: "there is a string word value called "BuildLab" which has the data value of  "2600.xpsp2.030422-1633""
Well, in that case, the REG QUERY method that we've been trying won't work..

You must use another method to check the value of the key, and compare it...

I haven't tested this but it should work:

:-----8<------------------------------------- FileName.bat --------------------------------------------:
@echo off

TITLE SP2 Installation Verifier
COLOR 70

CLS
ECHO.
ECHO Reading registry ...

PING -N 1 LOCALHOST >>NUL

REG QUERY HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion /v BuildLab > temp.txt

find /i "2600.xpsp2.030422-1633" temp.txt >>NUL
set err=%errorlevel%

del temp.txt

if %err% NEQ 0 (
   ECHO.
   ECHO It would appear that SP2 is NOT installed.
   ECHO.
   ECHO [press any key to exit]
   PAUSE >>NUL
   EXIT
)

ECHO.
ECHO It would appear the SP2 IS installed.
ECHO.
ECHO [press any key to exit]
PAUSE >>NUL
EXIT
:-----8<------------------------------------- FileName.bat --------------------------------------------:

gL,
[r.D]
0
 
kapesCommented:
ohh... then buildlab is not the key ...

for XP SP2 I check for the existence of KEY,

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows XP\SP2\KB11113

for XPSP1 I don't know, it might resamble something like this

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows XP\SP1

Go to this key ... and see.. what is the KBnumber under which it says "Windows XP Service Pack 1"
append that number at the end...as it is done for SP2 then change that in the script..

you have to change the script as following...


---------------- CheckSP1.vbs ------------------------------------
Dim RegPath, oWshShell, RegValue

RegPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows XP\SP1"

On Error Resume Next
Set oWshShell = CreateObject ("WScript.Shell")

RegValue = oWshShell.RegRead (RegPath)

If Err Then
'oWshShell.Popup "Error Accessing registry key (" & Err.Number & ") : " & Err.Description,0,"Check XP SP 1",vbCritical
oWshShell.Popup ":-( , XP SP1 is NOT installed",0,"Check XP SP 1",vbCritical
Err.Clear
Else
oWshShell.Popup "Registry path exists, so XP SP 1 is installed !!",0,"Check XP SP 1",vbInformation
End If

----------------------------------------------------------------

OR

if u going individually on each machine for checking it... then

run the follwing command at command prompt it will give you nice HTML table listing of all the patches installed on current machine...

wmic /output:%temp%\patches.htm qfe get /format:htable && start %temp%\patches.htm
0
 
lf_lakeAuthor Commented:
Many thanks to all who have helped so far.  '2600.xpsp2.030422-1633' is still showing as Service Pack 1 I am being led to believe that it differs whether you have a dell CD or a Corporate CD the build number is different
Thanks again


Many thanks to  DrWarezz for your solution
0
 
DrWarezzCommented:
;-)
0
 
kapesCommented:
did u try this command...

wmic /output:%temp%\patches.htm qfe get /format:htable && start %temp%\patches.htm
0
 
kapesCommented:
:-).... r u using the right key to check the SP2 is installed or not....

Did u read my comments...
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 5
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now