View Full Version : VBScript help

June 30 2011, 02:00:29 PM
So, I am trying to interrogate a 64bit Windows registry, and due to the fact it's 64bit you have to do things differently.

I am trying to get the Windows7 key in order to do some stuff with it, and it's location is here: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion, with the key being DigitalProductID

This script works on a Binary key in the same folder (AGTS), but if you change it to DigitalProductID, the contents of which are significantly longer, it returns a null value :( Any ideas, am i missing something really obvious?

strComputer = "."
Const HKLM = &h80000002
Set objReg = Getobject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer _
& "\root\default:stdregprov")
'Set up inParameters object
Set Inparams = objReg.Methods_("GetBinaryValue").Inparameters
Inparams.Hdefkey = HKLM
Inparams.Ssubkeyname = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
Inparams.Svaluename = "AGTSType"
set Outparams = objReg.ExecMethod_("GetBinaryValue", Inparams)

'Show output parameters object and the registry value HKLM\SOFTWARE\
WScript.Echo Outparams.GetObjectText_

Thanks in advance!

balistic void
June 30 2011, 02:05:26 PM
Get alphanumeric instead of binary?

June 30 2011, 02:10:31 PM
The reg type for both is REG_BINARY, so what works for AGTSType should work for DigitalProductID? Unless, as i said, i'm being a dunce

balistic void
June 30 2011, 02:24:16 PM
You using 32bit access or excel? What are you running the vbscript in? We had big problem with 64bit excel in the past.

June 30 2011, 02:28:02 PM
Neither, this is just VBscript saved as xxxxx.vbs, not VBScript in an app

Then the file is dbl clicked, and is probably run using a 32bit handler if my memory serves me. The method above does work for interrogating the registry as outlined,but not that one key :-\

June 30 2011, 02:48:17 PM
Code works fine for me. After changing Inparams.Svaluename = "AGTSType" to "DigitalProductID" I get...

ReturnValue = 0;
uValue = {My ProductId in decimal};


June 30 2011, 02:51:39 PM
LoudSpeakly- thats on a 64bit system?

June 30 2011, 02:53:24 PM
Ja. Win 7 ultimate x64.

June 30 2011, 02:58:18 PM
Hmm, OK thanks- that's interesting...

July 2 2011, 12:56:48 AM

Get-ItemProperty -Path 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name DigitalProductID

in Powershell. Because FUCK VBscript