WORKS FOR XP, VISTA, and probably WIN7
To
determine the current Windows NT Service Pack level installed, you can
query the registry, useful for script automation, using the following
Windows NT Registry hack:
Hive: HKEY_LOCAL_MACHINE
Key: system\CurrentControlSet\control\windows
Name: CSDVersion
Type: REG_DWORD
Value: 0x100 = SP1
Value: 0x200 = SP2
Value: 0x300 = SP3
Value: 0x400 = SP4
Value: 0x500 = SP5
Value: 0x600 = SP6
This
value does not distinguish SP6 from SP6a. If SP6a has been installed,
HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows
NT\CurrentVersion\Hotfix\Q246009\Installed will have a value of 1.