Solved

Identify Service Pack Via Command Line

Posted on 2009-05-03
14
2,918 Views
Last Modified: 2012-05-06
I am creating a boot cd and need to identify the service pack of the O/S installed.
I am primarily aiming at XP but if there is also a way for Vista that would be great.

Thanks
0
Comment
Question by:Moncapitaan
[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
  • 3
  • 3
  • +1
14 Comments
 
LVL 10

Accepted Solution

by:
Christian de Bellefeuille earned 74 total points
ID: 24289878
I don't know if it inform for Service pack, but usually to identify the version of windows the command is "VER".  It should return something like Microsoft Windows XP [Version 5.1.2600]

To get the SP with some VBScript... here's the code:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
Wscript.Echo objOperatingSystem.ServicePackMajorVersion _
& "." & objOperatingSystem.ServicePackMinorVersion
Next

Open in new window

0
 
LVL 10

Expert Comment

by:Christian de Bellefeuille
ID: 24289881
I'm sure that you could create an environment variable to store the SP number.
0
 
LVL 70

Assisted Solution

by:Qlemo
Qlemo earned 213 total points
ID: 24290085
PsInfo from SysInternals is able to ask remote for those infos, e.g. does
psinfo \\mycomputer | findstr /L /c:"Kernel" /c:"Service"
result in
Kernel version:            Microsoft Windows XP, Multiprocessor Free
Service pack:              3
Kernel build number:       2600
You could also use Registry: HKLM\Software\Microsoft\Windows NT\CurrentVersion\ with values BuildLab or BuildLabEx (comprehensive version string), or CSDBuildNumber or CSDVersion together with ProductName.
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 4

Author Comment

by:Moncapitaan
ID: 24290096
Thanks for the replies.

Questions:

1. Can I run VB script from a boot CD (booting to a command prompt in DOS (NTFS))
2. Can I inclide PsInfo on a boot CD I will distribute for free?
3. The CSD version sounds ok but how would I query the reg from boot cd?

Thanks
0
 
LVL 70

Assisted Solution

by:Qlemo
Qlemo earned 213 total points
ID: 24290126
1. Don't think so
2. no, distribution is prohibited by Microsoft, even if for free (AFAIK)
3. You need access to reg utility (build-in with XP and later, else Resource Kit / Support Tools): reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" | findstr "CSD ProductName"
0
 
LVL 4

Author Comment

by:Moncapitaan
ID: 24290155
reg utility? would this work from DOS?
0
 
LVL 70

Assisted Solution

by:Qlemo
Qlemo earned 213 total points
ID: 24290183
Depends on the "DOS" you use ... But it might be easier to use a tool to read the file version of some kernel files ...
"DOS" might not bring any resources to do what you want - regarding MFC or OS DLLs, aso.
0
 
LVL 5

Assisted Solution

by:AbqBill
AbqBill earned 213 total points
ID: 24577650
Hi, the answer depends on what you mean by 'DOS'. What operating system is booting from your CD? Is it really MS-DOS, or something like WinPE? If you need a Windows-based OS version testing utility, you could try my OSTEST program. It returns an exit code (ERRORLEVEL) based on the parameters you specify. For example:

ostest -p NT -v 5.1 -g -s 2

The above command will return an exit code of 1 if the current operating system is Windows XP (i.e., Windows NT 5.1) service pack 2 or greater. You can get OSTEST from my utility set here:

http://www.westmesatech.com/wast.html

Hope this helps. Bill.
0
 
LVL 4

Author Comment

by:Moncapitaan
ID: 24579705
Hi Bill,

Would it identify which service pack.  I would need to know if the system was running SP1, SP2 or SP3
0
 
LVL 5

Assisted Solution

by:AbqBill
AbqBill earned 213 total points
ID: 24581904
Yes, it can, using the -s option (see previous example). Also, the -g option means "greater than," so:

ostest -p NT v 5.1 -s 2

Returns an ERRORLEVEL 1 if the current operating system is exactly Windows XP SP2. If you put "-g" (meaning "greater than") before "-s" (as in the previous example), then it will return ERRORLEVEL 1 if the current operating system is Windows XP SP2 or any later service pack.

Keep in mind that OSTEST tests the currently running operating system, not an arbitrary OS that happens to be installed on a hard drive partition. Bill.
0
 
LVL 4

Author Comment

by:Moncapitaan
ID: 25616913
If I boot from a WinVista recovery cd and use the command prompt.  I want to know the OS inc SP installed on the HDD - is that possible with your tool? Is that possible without your tool and only using the command prompt?
0
 
LVL 5

Assisted Solution

by:AbqBill
AbqBill earned 213 total points
ID: 25617530
Hi Moncapitaan, my tool detects the running OS, not an arbitrary one on an OS partition. To do what you want, you could do a version check on a system file using filever.exe or the FVerTest.exe in my toolset:

http://www.westmesatech.com/wast.html

It may be tricky to get the service pack -- you might have to examine the last modification date of a system file as well as its version number. Bill.
0
 
LVL 4

Author Comment

by:Moncapitaan
ID: 25743097
Need help awarding this one:-

I didnt get a solution to my problem exactly as I needed it.  AND now the problem no longer exists! HOWEVER Bill (AbqBill) was very helpful.  I dont want to accept the answer as the solution as it isnt but it is helpful :-)

??
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

622 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