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

x
  • 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?
0
rfmcg
Asked:
rfmcg
  • 6
  • 5
1 Solution
 
MSGeekCommented:
What are you trying to accomplish, backing up that key or finding out who is sharing what?
0
 
rfmcgAuthor Commented:
I'm trying to back up the key
0
 
MSGeekCommented:
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.
0
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...
0
 
rfmcgAuthor Commented:
Yeah, unfortunately as quoted on that page...
"The export operation works only with the local computer"
0
 
MSGeekCommented:
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?
0
 
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.
0
 
MSGeekCommented:
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.
0
 
oBdACommented:
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.

=====remreg.cmd========8<---snip-----------------------------------
@echo off
setlocal
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%
:loop
for /f "tokens=1* delims=, " %%a in ("%ServerList%") do (
  call :process %%a
  set ServerList=%%b
)
if not "%ServerList%"=="" goto loop
goto leave

:process
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

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

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

:leave
=============8<---snip-----------------------------------
0
 
MSGeekCommented:
Well that sums it up for ya, thanks oBda.
0
 
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
0

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