V
vorpal
Reference:
http://msdn.microsoft.com/en-us/library/aa390455(VS.85).aspx
Test code:
const HKEY_LOCAL_MACHINE = &H80000002
Const HKCU=2147483649
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &
strComputer & "\root\default:StdRegProv")
strKeyPath = "software\khpp\jbm"
strValueName = "TestVal"
Return = objReg.GetExpandedStringValue(HKCU,_
strKeyPath,strValueName,strValue)
If (Return = 0) And (Err.Number = 0) Then
WScript.Echo "The Test Value is: " & strValue
Else
Wscript.Echo _
"GetExpandedStringValue failed. Error = " & Err.Number
End If
I lifted this test code directly from the above, and it works.
I pointed the GetExpandedStringValue to a different value as you can
see.
If I put "%windir% in TestVal, the output is "c:\windows"
If I put %LOGONSERVER% in TestVal, the output is "%LOGONSERVER%
Is there somewhere that documents which environment variables are
expanded?
Is there a way in vbScript to expand the others w/o resorting to
the ExpandEnvironmentStrings method?
I can live with ExpandEnvironmentStrings if I must, but I would like
to understand more about why I must.
Cheers,
Vorpal
:
http://msdn.microsoft.com/en-us/library/aa390455(VS.85).aspx
Test code:
const HKEY_LOCAL_MACHINE = &H80000002
Const HKCU=2147483649
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &
strComputer & "\root\default:StdRegProv")
strKeyPath = "software\khpp\jbm"
strValueName = "TestVal"
Return = objReg.GetExpandedStringValue(HKCU,_
strKeyPath,strValueName,strValue)
If (Return = 0) And (Err.Number = 0) Then
WScript.Echo "The Test Value is: " & strValue
Else
Wscript.Echo _
"GetExpandedStringValue failed. Error = " & Err.Number
End If
I lifted this test code directly from the above, and it works.
I pointed the GetExpandedStringValue to a different value as you can
see.
If I put "%windir% in TestVal, the output is "c:\windows"
If I put %LOGONSERVER% in TestVal, the output is "%LOGONSERVER%
Is there somewhere that documents which environment variables are
expanded?
Is there a way in vbScript to expand the others w/o resorting to
the ExpandEnvironmentStrings method?
I can live with ExpandEnvironmentStrings if I must, but I would like
to understand more about why I must.
Cheers,
Vorpal
: