cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
sticky
Engaged Sweeper III
Hi,

I often need to connect to a remote registry using regedit to check settings etc. I couldn't figure out how to do it from the command line (if someone knows, please share!), so I wrote a quick AutoIT script to do it. Convert to .exe, copy to a suitable location and create the following custom action:

Have attached the .exe to this post for others to use. The AutoIT code is below.


;
; AutoIt Version: 3.3
; Language: English
; Platform: Win2000/XP/Vista/2008
; Author: Michael Ward
;
; Script Function:
; Connects to a remote registry using regedit
;
#requireadmin

if ($CmdLine[0] > 0) Then
$hostname = $CmdLine[1]
Else
MsgBox(48,"Error","No Hostname Specified",60)
Exit(1)
EndIf

; Run Regedit
Run("regedit.exe")


; Wait for the regedit to become active
WinWaitActive("Registry Editor")

; Connect to the remote registry
Send("!f")
Send("c")
WinWaitActive("Select Computer")
Send($hostname)
Send("{ENTER}")

; Finished!


Action:
{actionpath}remote_regedit.exe {smartname}
9 REPLIES 9
cstoop
Engaged Sweeper
It is not working for me on domain computers. I have made a action and command: {actionpath}remote_regedit.exe \\{smartname}

When choose a asset and Regsitry on the let site which is the name of above command first i get UAC message i use then YES for yes permissions to do but then nothing happens..

DavidCNZ
Engaged Sweeper
This isn't working for me, we have UAC set to the default level. It does open the remote registry but you can't see or access most keys.

If I run regedit manually I get a UAC warning asking if I want to allow regedit to make changes to this computer. Picking 'Yes' gives me full registry access with all the keys showing. Running it from the compiled script I don't get prompted and only a few keys are readable.

It's like #requireadmin needs to be turned down a notch. Any suggestions?
moore_mat
Engaged Sweeper III
I've found on our Windows 7 domain-connected PCs the RemoteRegistry service is stopped, which prevents this from running. You can manually run the "SC.exe" program to start the service first:-
sc \\<pcname> start "RemoteRegistry"


But being the tweaking-kind; I added a line to the autoIT script that does it automatically.

It goes before the Run Regedit line like this:-



;
; AutoIt Version: 3.3
; Language: English
; Platform: Win2000/XP/Vista/2008
; Author: Michael Ward
;
; Script Function:
; Connects to a remote registry using regedit
;
#requireadmin
if ($CmdLine[0] > 0) Then
$hostname = $CmdLine[1]
Else
MsgBox(48,"Error","No Hostname Specified",60)
Exit(1)
EndIf

; Start up Remote Registry access
RunWait('sc.exe '&$hostname&' start "RemoteRegistry"')



; Run Regedit
Run("regedit.exe")



; Wait for the regedit to become active
WinWaitActive("Registry Editor")

; Connect to the remote registry
Send("!f")
Send("c")
WinWaitActive("Select Computer")
Send($hostname)
Send("{ENTER}")

; Finished!



You then need to change the action line to put in the two backslashes in front of the PC name:-
{actionpath}remote_regedit.exe \\{smartname}



A big thank you to Michael for the script in the first place (and Dan for the admin line!)!
esserto
Engaged Sweeper
I could not get this to work in my network.

Our clients have Windows 7 Prof. x64 installed.


All times come the error message: No Hostname Specified

What i can do ??

Sorry for my bad english 🙂
danscallon
Engaged Sweeper II
I could not get this to work after migrating to Windows 7/8
Finally found how to make it work!

#RequireAdmin

Specifies that the current script requires full administrator rights to run.

I just put #RequireAdmin at the top of the AutoIT script and made a new executable

Thanks to Michael Ward for creating this script

;
; AutoIt Version: 3.3
; Language: English
; Platform: Win2000/XP/Vista/2008
; Author: Michael Ward
;
; Script Function:
; Connects to a remote registry using regedit
;

#requireadmin
if ($CmdLine[0] > 0) Then
$hostname = $CmdLine[1]
Else
MsgBox(48,"Error","No Hostname Specified",60)
Exit(1)
EndIf

; Run Regedit
Run("regedit.exe")


; Wait for the regedit to become active
WinWaitActive("Registry Editor")

; Connect to the remote registry
Send("!f")
Send("c")
WinWaitActive("Select Computer")
Send($hostname)
Send("{ENTER}")

; Finished!

GerardSweeney
Engaged Sweeper
At the risk of showing bad form and resurrecting an old thread, I've modified this code slightly for my own use.

I've adapted this for my Altiris DS console so that I can right click on the computer in the DS console and access the registry directly.

If you don't want the options embedded, it'd be relatively simple to read an ini file with iniread($inifile, "Settings", "OnePCPerWindow, "Y")

Please don't laugh too hard at my hideous coding 🙂


;
; AutoIt Version: 3.3
; Language: English
; Platform: Win2000/XP/Vista/2008
; Author: Michael Ward
; Modification by Gerard Sweeney, 2011
;
; Script Function:
; Connects to a remote registry using regedit
;

; Choices here - if you don't want multiple PCs open in the one
; regedit window, we can present some choices
; OnePCPerWindow - Close Regedit first before opening the specified PC
; Prompt - Ask the user if they want to close regedit first
; Note that setting OnePCPerWindow to "N" over-rides $Prompt

$OnePCPerWindow = "N"
$Prompt = "Y"


if ($CmdLine[0] > 0) Then
$hostname = $CmdLine[1]
Else
MsgBox(48,"Error","No Hostname Specified",60)
Exit(1)
EndIf

$P = "regedit.exe"
$T = "Registry Editor"



; Run Regedit if it isn't already running
If ProcessExists($P) <> 0 then
If $OnePCPerWindow = "Y" then
If $Prompt = "Y" then
$Q = Msgbox(35, "Regedit already open", "Regedit is already running." & @CRLF & @CRLF & "Do you want to open the registry for PC " & $HostName & " in this window?" & @CRLF & @CRLF & "Yes = Open in current window" & @CRLF & "No = Close current Regedit window first" & @CRLF & "Cancel = do not attempt to open the remote registry at all")
Select
Case $Q = 7
; No clicked
ProcessClose($P)
ProcessWaitClose($P,10)

Case $Q = 6
; Yes clicked

Case Else
; Cancel
EXIT
EndSelect
Else
ProcessClose($P)
ProcessWaitClose($P,10)
EndIf
EndIf
EndIf

If ProcessExists($P) = 0 then
Run($P)
; Wait for the regedit to become active
WinWaitActive($T)
EndIf

WinActivate($T)
WinWaitActive($T)

; Connect to the remote registry
Send("!f")
Send("c")
WinWaitActive("Select Computer")
Send($hostname)
Send("{ENTER}")

; Finished!
Damien
Engaged Sweeper
Is there a way to do a mass registry edit using this command?
mrdaytrade
Engaged Sweeper III
VERY NICE! I've been looking for a way to do this for sometime now. Thanks!
taeratrin
Champion Sweeper
Regedit commandline switches include :

/L:system Specify the location of the system.dat to use
/R:user Specify the location of the user.dat to use

I would imagine pointing those to the (admin share + appropriate path) on the remote computer would do the trick.