Solved

Identify Service Pack Via Command Line

Posted on 2009-05-03
14
2,916 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:
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 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
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.

 
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

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…
Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

734 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