Solved

Identify Service Pack Via Command Line

Posted on 2009-05-03
14
2,909 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
  • 5
  • 3
  • 3
  • +1
14 Comments
 
LVL 10

Accepted Solution

by:
cdebel 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:cdebel
ID: 24289881
I'm sure that you could create an environment variable to store the SP number.
0
 
LVL 69

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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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 69

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 69

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

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…
One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

773 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