Remote Registry – Where there’s a WIL there’s a way

 

I have been a huge fan of WinBatch since 1997. WinBatch, a fantastic scripting utility provided by Wilson WindowWare, is based on the Windows Interface Language (WIL).

I have gotten out of more than one tight spot with WinBatch. I intend to use this forum to post scripts which I have used through the years which have helped me with my systems management duties.

The following script is designed to open up the Registry via Regedit.exe. It will then connect to a remote machine (based off of the Argument passed). In other words, if I wanted to open the registry of a remote computer called Homer, I would simply just have to run

StartReg.exe homer

Below is the WinBatch script

; This script will open a separate window for Regedit and connect to the target machine
ErrorMode(@Off)

systemroot=Environment(“SystemRoot”)

if isDefined(param1)
param1 = strTrim(param1)
if FileExist(StrCat(systemroot,”regedit.exe”))
run(StrCat(systemroot,”regedit.exe”), “-m”)
winCheck = WinWaitExist(“Registry Editor”, 5)
if winCheck == @False then exit
IgnoreInput(@TRUE)
GetWindow = DllHwnd(“Registry Editor”)
ID=WinIdGet(“Registry Editor”)
winActivate(ID)
SendKeysTo(ID, “!FC”)
scCheck = WinWaitExist(“Select Computer”, 4)
if scCheck == @False
IgnoreInput(@FALSE)
display(5, “Error”, “Error connecting to Remote Registry”)
exit
endif
SCID = WinIdGet(“Select Computer”)
SendKeysTo(SCID, “!E”)
SendKeysTo(SCID, param1)
SendKeysTo(SCID, “!c”)
MouseClickBtn(SCID, “”, “OK”)
IgnoreInput(@FALSE)
endif
else
message(“Error”, “Please pass name of remote computer as argument (e.g. StartReg.exe homer)”)
endif

There you go. Unfortunately I have NOT found a better way to automatically connect to a remote registry without having to automate the key strokes. Oh well, it may be kludgy but it works.