Jump to content

How to properly query the service pack version from the registry


Recommended Posts

Posted

Can anyone tell me whats wrong with this command?

reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion\CSDVersion"

Thanks in advance!


Posted

That's a huge step in the right direction but does anyone know how to save the result of the reg query command to a variable? Ive tried using %1%, %1 and %%i in the following manner:

for /f "skip=4 tokens=3" %%? in ('HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v CSDVersion') do set CSDVersion=%%?
set CSDVersion=%CSDVersion:~-3%

reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v CSDVersion"
if %1% == "Service Pack 1" go to runupdates
if %1% == "Service Pack 2" go to end

On another note, I found this link that has what I need but I cant seem to get the syntax of the IF and GO TO statements correct: http://fixunix.com/ms-dos/271139-read-os-s...evel-batch.html

Thanks in advance!

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...