Hi
I have a script that I am writing that will connect to a server remotely and read a registry value (type is REG_SZ). The script appears to reach the end but stops with the runtime error: Invalid use of Null: 'Value'
To help here is a snippet of the code that generates the error:
Sub RegistrySize
Dim strKeyPath
Dim strValueName
Dim dwValue
Dim objReg
Dim objWMIConnect
Dim logfile
Const HKEY_LOCAL_MACHINE = &H80000002
wscript.echo "hello"
Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIConnect = SWBemlocator.ConnectServer(strComputer,"\root\default",Name,passWord)
wscript.echo "hi"
strKeyPath = "SOFTWARE\Infrastructure"
strValueName = "Build Number"
Set objReg=objWMIConnect.get("stdRegProv")
wscript.echo strValuename
objReg.getstringvalue HKEY_LOCAL_MACHINE, strKeyPath, strValueName,Value
msgbox value
End Sub
Note: All the required variables have been set-up above the function and this has been tested on several servers!
Any help would be appreciated!
Ps Does any one have another way to connect to a remote server that allows you to pass credentials?
I have a script that I am writing that will connect to a server remotely and read a registry value (type is REG_SZ). The script appears to reach the end but stops with the runtime error: Invalid use of Null: 'Value'
To help here is a snippet of the code that generates the error:
Sub RegistrySize
Dim strKeyPath
Dim strValueName
Dim dwValue
Dim objReg
Dim objWMIConnect
Dim logfile
Const HKEY_LOCAL_MACHINE = &H80000002
wscript.echo "hello"
Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIConnect = SWBemlocator.ConnectServer(strComputer,"\root\default",Name,passWord)
wscript.echo "hi"
strKeyPath = "SOFTWARE\Infrastructure"
strValueName = "Build Number"
Set objReg=objWMIConnect.get("stdRegProv")
wscript.echo strValuename
objReg.getstringvalue HKEY_LOCAL_MACHINE, strKeyPath, strValueName,Value
msgbox value
End Sub
Note: All the required variables have been set-up above the function and this has been tested on several servers!
Any help would be appreciated!
Ps Does any one have another way to connect to a remote server that allows you to pass credentials?