13

Is there is a way to get service pack number from command line? Or the build number from command line (from which I can tell the service pack number (see How do I determine Windows Version and Service Pack from WindowsUpdateLog.txt))?

Upon starting cmd, part of the Windows version number is shown on the screen, but not the service pack number.

I prefer a non-PowerShell answer, but I wouldn't mind knowing about a PowerShell answer anyways since some computers I deal with do have it installed.

Alexander Bird
  • 1,827
  • 4
  • 19
  • 25
  • Other related websites: http://www.eggheadcafe.com/software/aspnet/29718402/how-to-check-service-packs-on-remote-computers.aspx and http://support.microsoft.com/kb/279631 – Alexander Bird Oct 18 '10 at 18:56

5 Answers5

15

systeminfo | findstr /B /C:"OS Name" /C:"OS Version"

Source: Find windows version from command prompt

Wasif
  • 7,984
  • 2
  • 19
  • 32
Giri
  • 559
  • 2
  • 7
  • This is the only one that works on all computers I've tried these methods on. – Alexander Bird Oct 08 '10 at 19:20
  • ps - the above only works if the user language is English, since the string filter uses the English names. Using systeminfo on its own will work for any language - though requires manual effort searching through all the data returned. – JohnLBevan Oct 03 '12 at 13:59
10

You can get it using WMIC - wmic os get servicepackmajorversion

For more on using WMIC, see this little tutorial: http://quux.wiki.zoho.com/WMIC-Snippets.html

Wasif
  • 7,984
  • 2
  • 19
  • 32
Multiverse IT
  • 4,478
  • 16
  • 22
  • Is wmic installed on all Windows computers? for some reason, my home computer does not recognize `wmic`. – Alexander Bird Oct 01 '10 at 16:51
  • 1
    Awesome tool, thanks for sharing! @Thr4wn, according to Wikipedia, WMIC is not available on Windows XP Home Edition, but is available on XP Pro and all later versions of Windows. – nhinkle Oct 01 '10 at 20:18
6

You can type in CMD:

Winver

r0ca
  • 5,727
  • 10
  • 42
  • 63
1

You can get it from the command line by querying the registry for the ServicePack key. If an SP is installed, it will be shown, otherwise, it will say that it was unable to locate the specified key, in which case there is no service pack.

reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v ServicePack
nhinkle
  • 37,198
  • 36
  • 140
  • 177
  • This only works if there is a Service Pack installed (e.g. currently Windows 7 does not have a Service Pack so the key does not exist) – misterjaytee Oct 01 '10 at 11:14
  • I know; that's what I stated in my answer. If the key doesn't exist, then there is no service pack, thus it is SP0. If the key does exist, it'll tell you the service pack. So either way, you can figure out what service pack (if any) is installed. – nhinkle Oct 01 '10 at 20:17
  • When I try Giri's solution, it shows SP 3, but this method reports that it was unable to find the specified registry key or value (I copied/pasted the command into cmd). – Alexander Bird Oct 08 '10 at 19:19
  • Instead of "ServicePack", you can use "ProductName" and "CSDVersion" – d.moncada Sep 25 '15 at 15:52
0

You can use this:

wmic os get csdversion /format:value
Wasif
  • 7,984
  • 2
  • 19
  • 32