I am not a programming professional but I am enjoying it, below is an attempt to read a remote registry, remote machine is specified by an inputbox which can be computername or Ip address, and verify a key. later on in the functionality of the project, the key will be used to create a path to begin copying profile data in a computer refresh. I am receiving the error on line 32. it states that there is a type mismatch. I have verified that it is an expanded string on my machine, as well as the target test machine. I have tried also GetStringValue instead, which yields the same error.
Again, any help is appreciated, and thank you.
Option Explicit
dim objWMIService, objRemoteWMIService, objWshNet, objFSO, objAccount, objShell, objReg
dim strComputer, strRemoteComputer, strLIUser, strLIUserSID, strTargetuser, strLIDomain, strpartfilepath, strRegPartProfilePath, strRegProfilePath, strRegKeyPath, strValue, strRegKeyValueName
dim intTest
'Step 1:
set objWshNet = WScript.CreateObject("WScript.Network")
strLIUser = objWshNet.UserName
strLIDomain = objWshNet.UserDomain
strpartfilepath = "C:\documents and settings\"
strComputer = "." 'inputbox("What is the target computer's ip Address?")
'Wscript.echo strComputer
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objAccount = objWMIService.Get _
("Win32_UserAccount.Name='" & strLIUser & "',Domain='" & strLIDomain & "'")
strLIUserSID = objAccount.SID
StrRemoteComputer = inputbox("What is your old computer's IP Address?", "Old PC IP Address")
Set objRemoteWMIService = GetObject("winmgmts:\\" & strRemoteComputer & "\root\default:StdRegProv")
'Test Echo
Wscript.Echo "on computer : " & strComputer &vbnewline & "User : " & strLIUser & vbnewline & " SID : "& strLIUserSID
set objFSO = CreateObject("Scripting.FileSystemObject")
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strRemoteComputer & "\root\default:StdRegProv")
strRegKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\" & strLIUserSID
strRegkeyValueName = "ProfileImagePath"
objReg.GetExpandedStringValue "HKEY_LOCAL_MACHINE",strRegKeyPath,strRegKeyValueName,strValue
wscript.echo "in the case of "&strLIUser& " on " & strRemoteComputer & vbnewline &_
"The key path is : " & strRegKeyPath & vbnewline &_
"the key value name is :" & strRegKeyValueName & vbnewline &_
"the key value is :" & strValue
'WScript.Echo "Registry key path: " & strRegKeyPath & vbnewline & "Key Value: " &strRegProfilePath' check this against your profile lsit sid location and verify data
wscript.echo "End of File"

New Topic/Question
Reply




MultiQuote





|