Create registry key Under HKLM-software-microsoft-windows-currentversion-run

I need to create registry key Under HKLM-software-microsoft-windows-currentversion-run
The key tiltle will by xyz and it should read a file path to execute.  I have to make this change to multiple servers remotely.  Please advise
rezzmanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

guydemarcoCommented:
Copy the below into a notepad text file. Modify as needed, then save. Rename the file extension to .REG and you can auto-import it into any registry.
Windows Registry Editor Version 5.00
 
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"XYZ"="C:\\Program Files\\Your Directory\\YourExecutable.exe"

Open in new window

0
-JerodRCommented:
Create the key on a computer using regedit (start > run > regedit).  Right click the key and export it.  Then you can copy the .reg file it creates to the remote computers and execute it.  After the .reg file is executed on the remote machine, the new key will be added to the registry on the remote machine.
0
guydemarcoCommented:
A .REG file, by the by, is executable to import into the registry. Make sure you modify that last line to what you need, the rest should work as-is. Don't forget the double slashes on the last line of the code I posted.
0
arshanaCommented:
you would need some kind of a software that allows you to modify registry of multiple computers from one place. I assume you are using a domain environment. Try using ideal dispatch (http://www.pointdev.com) it should help.
0
oBdACommented:
You have everything you need to do this remotely on your XP/W2k3 machine: reg.exe
reg.exe is able to add entries to remote machines as well, and with the aid of a batch script, you can do the lot at once.
The basic command (from a command prompt) would be

reg.exe add "\\<RemoteServerNameOrIPAddress>\HKLM\Software\Microsoft\Windows\CurrentVersion\Run" /v "xyz" /d "C:\Wherever\program.exe" /f

How many servers are we talking about here?
The easiest way to do this for several machines is to use a batch script (save as regrun.cmd or whatever.cmd) like the one below; just change the ServerList variable to contain your list of servers.
If the number of machines is getting way into the double digits, the second example might be easier, where you provide a list with the machine names in it (one server name/IP address per line).
Note that in order for your to test them, both scripts are in test mode; they will only print out the reg.exe command they would normally run.
To run them for real, remove the capitalized ECHO in front of reg.exe.
REM ----- Begin example 1 -----
@echo off
setlocal
set ServerList=Server1 Server2 Server3 Server4 Server5
set RunTitle=XYZ
set RunProgram=C:\Wherever\program.exe
for %%a in (%ServerList%) do (
  echo Processing %%a ...
  ECHO reg.exe add "\\%%a\HKLM\Software\Microsoft\Windows\CurrentVersion\Run" /v "%RunTitle%" /d "%RunProgram%" /f
)
REM ----- End example 1 -----
 
REM ----- Begin example 2 -----
@echo off
setlocal
set ServerFile=C:\Temp\Serverlist.txt
set RunTitle=XYZ
set RunProgram=C:\Wherever\program.exe
for /f %%a in ('type "%ServerFile%"') do (
  echo Processing %%a ...
  ECHO reg.exe add "\\%%a\HKLM\Software\Microsoft\Windows\CurrentVersion\Run" /v "%RunTitle%" /d "%RunProgram%" /f
)
REM ----- End example 2 -----

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Legacy OS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.