T
T
tony_keller2014-12-25 17:16:14
Windows
tony_keller, 2014-12-25 17:16:14

How to create a registry branch on a remote computer via vbs by searching by strSID?

Where is the mistake?
On Error Resume Next
const HKEY_USERS = &H80000003
UserName = "USERNAME" 'Windows username whose HKEY_CURRENT_USER needs to be read on another machine
CompName = "train-plazma" 'Computer name where the registry needs to be read
Key = "AppEvents" 'subkey in HKEY_CURRENT_USER to read
'get the user's SID
Set objWMIService = GetObject("winmgmts:{ImpersonationLevel=Impersonate}!\\.\root\cimv2")
If Err.Number <> 0 Then
WScript.Echo Err.Number & ": " & Err.Description
WScript.Quit
End If
Set colItems = objWMIService.ExecQuery("Select * from Win32_UserAccount WHERE Name = "
strSID = Trim(objItem.SID)
Exit For
Next
'Creating
keys intRes = objReg.CreateKey(HKEY_USER, "test\tes1")
If intRes <> 0 Then
WScript.Echo intRes & ": Failed to create registry keys"
WScript.Quit
End If
'Creating parameters
intRes = objReg.SetStringValue(HKEY_USER, "test\test1", "test_par", "test_val")
If intRes <> 0 Then
WScript.Echo intRes & ": Failed to set parameter '"HKEY_USER\test\" test1\test_par"""
WScript.Quit
End If
intRes = objReg.SetStringValue(HKEY_CURRENT_USER, "AppEvents", "", "MyDefaultValue")
If intRes <> 0 Then
WScript.Echo intRes & ": Failed to set option '"HKEY_USER\AppEvents\(Default)"""
WScript.Quit
End If
'Display messages
WScript.Echo "Settings created: '
WScript.Echo "HKEY_USER\AppEvents\test\ test1\test_par(value ""test_val"")"
WScript.Echo "HKEY_USER\AppEvents\(Default)(value ""MyDefaultValue"")"

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question