Modify Registry
- From: Rick <drummer10980@xxxxxxxxx>
- Date: Tue, 8 Jan 2008 06:34:51 -0800 (PST)
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
.
- Prev by Date: Re: Open running Outlook instance
- Next by Date: Re: Writing Script for ScanDisk and Defrag
- Previous by thread: Re: checking processes
- Next by thread: Re: Classic Start Menu
- Index(es):
Relevant Pages
|