Solved

Identify Service Pack Via Command Line

Posted on 2009-05-03
14
2,907 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
Comment Utility
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
Comment Utility
I'm sure that you could create an environment variable to store the SP number.
0
 
LVL 68

Assisted Solution

by:Qlemo
Qlemo earned 213 total points
Comment Utility
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
 
LVL 4

Author Comment

by:Moncapitaan
Comment Utility
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 68

Assisted Solution

by:Qlemo
Qlemo earned 213 total points
Comment Utility
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
Comment Utility
reg utility? would this work from DOS?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 68

Assisted Solution

by:Qlemo
Qlemo earned 213 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now