Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 267
  • Last Modified:

run the regedit /e command from a utility workstation against several servers

I want to setup a process that exports the lanmanserver key to a reg file, But I want to setup the process to run from a remote machine.   Is there a way to run a cmd similar to this "regedit /e c:\test\test.reg "hkey_local_machine\system\currentcontrolset\services\lanmanserver\shares" but get it to go out to several servers and export the .reg file to each server locally?
  • 6
  • 5
1 Solution
What are you trying to accomplish, backing up that key or finding out who is sharing what?
rfmcgAuthor Commented:
I'm trying to back up the key
That would require the same account on the remote machine be on all the target machines with the same password, otherwise your batch file would be passing a clear text password each time regdt32 authenticates to each individual machine.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

rfmcgAuthor Commented:
Yeah, no problem there, I'm a admin of all the boxes...
rfmcgAuthor Commented:
Yeah, unfortunately as quoted on that page...
"The export operation works only with the local computer"
Regedit is local as well.  Regedt32 will access remote registries but has no command line options that I am aware of.  Could you excute your script as part of a scheduled task to a network share or local directory?
rfmcgAuthor Commented:
So basicly you are saying schedule a task on each of the servers whose key i'm trying to back up?  Yeah, I'm assuming I can do that.   I was hoping I could use a box here that I have other scheduled tasks on, scheduling one task/script to run and go out backing up the keys I need backed up.
It could be done as one file which calls scripts on the servers executing the reg command which could direct all dumps to a common share, you would have to have seprate directories for each server or specify a different filename for each server's dump.
Hi rfmcg,

as always when you want something to execute on a remote machine with the least effort, you can use at.exe (well, the resource kit's "soon.exe" in this case.)
You can start with this; you can schedule it using Control Panel (not at.exe) and domain credentials, and it will then in turn schedule the backup tasks on each computer in the list.
It creates a logfile in the batch file's directory, with the name of the command file and its extension.

@echo off
rem *** A list of servers to process, separated by commas:
set ServerList=Server1,Server2
rem *** Target Directory and Prefix of the registry file (on remote computer)
rem *** - %Computername%.reg will automatically be added
rem *** - No spaces allowed in path or file name
set FileName=C:\Test\Shares-
rem *** Time to wait before the task starts:
set Delay=900
rem *** Create a logfile with the name of the command file in its directory, with the extension .log:
set Logfile=%~dpn0.log

if exist %Logfile% del %Logfile%
for /f "tokens=1* delims=, " %%a in ("%ServerList%") do (
  call :process %%a
  set ServerList=%%b
if not "%ServerList%"=="" goto loop
goto leave

set Target=%1
ping -n 1 %Target% | find "TTL" >NUL
if errorlevel 1 goto err_Alive
soon \\%Target% %Delay% "regedit /e %FileName%%Target%.reg HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\lanmanserver\Shares" >NUL
at \\%Target% | find /i "regedit /e %FileName%%Target%.reg" >NUL
if errorlevel 1 goto err_Schedule
echo %Target%: Backup successfully scheduled.>>"%LogFile%"
goto :eof

echo %Target%: Couldn't schedule job, not responding.>>"%Logfile%"
goto :eof

echo %Target%: Unable to schedule job (check credentials and service).>>"%Logfile%"
goto :eof

Well that sums it up for ya, thanks oBda.
rfmcgAuthor Commented:
Thanks oBda.   I just tested it and your solution works.  Thanks!!  Also thanks MSGeek for your help also...
This site rocks...
Now I gotta get up to speed and learn how to figure this stuff out myself!

Thanks again

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now