Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Batch with reg Query for XP SP1 installed

Posted on 2004-10-30
13
Medium Priority
?
1,039 Views
Last Modified: 2008-01-09
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
Comment
Question by:lf_lake
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
  • +1
13 Comments
 
LVL 34

Expert Comment

by:sramesh2k
ID: 12455835
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
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12456449
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
 
LVL 6

Expert Comment

by:kapes
ID: 12462709
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:lf_lake
ID: 12497554
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
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12498404
Very strange -- have you tried sramesh2k's idea?

[r.D]
0
 
LVL 6

Expert Comment

by:kapes
ID: 12502036
r u sure... u r checking the right key for existence of SP1 ?

0
 

Author Comment

by:lf_lake
ID: 12515083
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
 
LVL 9

Accepted Solution

by:
DrWarezz earned 1500 total points
ID: 12516779
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
 
LVL 6

Expert Comment

by:kapes
ID: 12521628
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
 

Author Comment

by:lf_lake
ID: 12527095
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
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12527316
;-)
0
 
LVL 6

Expert Comment

by:kapes
ID: 12532550
did u try this command...

wmic /output:%temp%\patches.htm qfe get /format:htable && start %temp%\patches.htm
0
 
LVL 6

Expert Comment

by:kapes
ID: 12656126
:-).... r u using the right key to check the SP2 is installed or not....

Did u read my comments...
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Migration of Exchange mailbox can be done with the ExProfre.exe tool. But at times, when the ExProfre.exe tool migrates the Exchange Server user profile, it results in numerous synchronization problems. Synchronization error messages appear in the e…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question