Modify Registry

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Not sure if this is the right forum for my question, but here is goes.
I'm trying to remotely change a registry key. Below is my script and I
cannot get it to change

1. The AutoAdminLogon for 1 to 0.
2. Then change back the AutoAdminLogon to 1 and change the
DefaultUserName to Admin1.


thanks in advance
rick

Dim ComputerName
'====================================================================


'ComputerName = InputBox("Please Enter a preferred computer
name:")
ComputerName = "Computer1"
strComputer = ComputerName

'====================================================================


Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer
& "\root\cimv2")
'====================================================================


Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_
strComputer & "\root\default:StdRegProv")

'==================================================

strKeyPath = "SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon"
KeyPath = "SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon"
strValueName = "AutoAdminLogon"
strValue = "0"



' Create key to use
Return = objReg.CreateKey(HKEY_LOCAL_MACHINE, KeyPath)
If (Return = 0) And (Err.Number = 0) Then
Wscript.Echo "HKEY_LOCAL_MACHINE\Software\MyKey created"

' write string value to key
Return = objReg.SetStringValue( _
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue)
WScript.Echo SetStringValue
If (Return = 0) And (Err.Number = 0) Then
Wscript.Echo "HKEY_LOCAL_MACHINE\Software\MyKey" & _
" contains 'string value'"
Else
Wscript.Echo "SetStringValue failed. Error = " & Err.Number
End If
Else
Wscript.Echo "CreateKey failed. Error = " & Err.Number
End If
.



Relevant Pages

  • Find & Replace
    ... After all occurences are found, I must them with the actual computername, ... Dim FileName, Find, ReplaceWith, FileContents, dFileContents, ... 'Find String in file ... 'Wscript.Echo "Searched string Not In the source file" ...
    (microsoft.public.scripting.vbscript)
  • Re: Domaenen Kennwoerter aendern
    ... >> oldPassword As String, ByVal newPassword As String) As String ... > Wo kommt splitUserName her? ... Du kannst den lokalen Computername ... System.Reflection.BindingFlags.GetProperty, Nothing, x, Nothing) ...
    (microsoft.public.de.german.entwickler.dotnet.asp)
  • Re: Computer Name with VBA
    ... Dim computername As String ... Sub Get_Computer_Name_Ex ...
    (microsoft.public.excel.programming)
  • Re: Get System Information
    ... Dim sUser As String ... Set oWMI = GetObject ... Public Function ComputerName() As String ...
    (microsoft.public.vb.general.discussion)
  • Re: Modify Registry
    ... Dim ComputerName ... strValueName = "AutoAdminLogon" ... Return = objReg.CreateKey(HKEY_LOCAL_MACHINE, strKeyPath) ...
    (microsoft.public.scripting.wsh)