HalCHub
asked on
getting values from the registry win 7 vbs
Hello given the following code:
strComputer = "."
Const HKCU = &H80000001 'HKEY_CURRENT_USER
strKeyPath = "Software\x\y"
szvalue = " "
szvaltype = " "
strname="z"
Set oReg= _
GetObject("winmgmts:{imper sonationLe vel=impers onate}!\\" _
& strComputer & "\root\default:StdRegProv" )
oReg.GetStringValue HKcu, strKeyPath, strname, szValue
wscript.echo szvalue
Where z is a reg_sz with a value of 1 does the code above echo reg_sz and not the value 1 ?
strComputer = "."
Const HKCU = &H80000001 'HKEY_CURRENT_USER
strKeyPath = "Software\x\y"
szvalue = " "
szvaltype = " "
strname="z"
Set oReg= _
GetObject("winmgmts:{imper
& strComputer & "\root\default:StdRegProv"
oReg.GetStringValue HKcu, strKeyPath, strname, szValue
wscript.echo szvalue
Where z is a reg_sz with a value of 1 does the code above echo reg_sz and not the value 1 ?
the above should return 1, what's the problem? try to run the code in elevated permission (right click, run as administrator)
ASKER
I ran as administrator it returns reg_sz
i just ran your code on xp and win7, they both return 1
and it gives a runtime error (invalid use of null) if the key does not exist!
is this the exact code your using? or your modifying it for experts exchange? if so, check your code, you might have a typo!
i'm using win7 ultimate sp1;
and xp sp3
and it gives a runtime error (invalid use of null) if the key does not exist!
is this the exact code your using? or your modifying it for experts exchange? if so, check your code, you might have a typo!
i'm using win7 ultimate sp1;
and xp sp3
ASKER
nope its the exact code
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.