Sysinternals Homepage
Forum Home Forum Home > Sysinternals Utilities > PsTools
  New Posts New Posts RSS Feed: Running Regedit on remote system
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Running Regedit on remote system

 Post Reply Post Reply
Author
Message Reverse Sort Order
Creed View Drop Down
Newbie
Newbie


Joined: 16 October 2006
Online Status: Offline
Posts: 4
Post Options Post Options   Quote Creed Quote  Post ReplyReply Direct Link To This Post Topic: Running Regedit on remote system
    Posted: 15 February 2007 at 2:33am
Have you seen desktop authority ?
It's ideal solution for pushing registry changes on remote machines.
With validation logic of desktop authority this changes can be delivered only to certain users according to a ton of different criterias.
Back to Top
Karlchen View Drop Down
Senior Member
Senior Member
Avatar

Joined: 18 June 2005
Location: Germany
Online Status: Offline
Posts: 5121
Post Options Post Options   Quote Karlchen Quote  Post ReplyReply Direct Link To This Post Posted: 05 February 2007 at 4:54pm
Hi, jtwatsn.

Sorry, it looks as if Gerry and me managed to confuse you by dicussing pros and cons of different approaches, whereas you just would like to know 1.

"regedit.exe /s name_of_file.reg" can import a reg-file of any length without prompting to import it. It will simply do it.

So one possible approach to solve your issue was given in my very first answer:
The "messy" (Gerry's word) solution/workaround

Karl
Back to Top
jtwatsn View Drop Down
Newbie
Newbie


Joined: 02 February 2007
Online Status: Offline
Posts: 2
Post Options Post Options   Quote jtwatsn Quote  Post ReplyReply Direct Link To This Post Posted: 05 February 2007 at 8:56am
I appreciate all the input.  What I'm trying to achieve is updating all the W2K machines for the upcoming Daylight Savings Time change.  Therefore, I was needing to change a large amount of data, and had planned on trying to import it in.  I started with WMI, but it had its own issues doing remote manipulation.  From a brief look, I'm not sure if any of the other tools mentioned will allow importing a reg file.
Back to Top
Karlchen View Drop Down
Senior Member
Senior Member
Avatar

Joined: 18 June 2005
Location: Germany
Online Status: Offline
Posts: 5121
Post Options Post Options   Quote Karlchen Quote  Post ReplyReply Direct Link To This Post Posted: 04 February 2007 at 4:49pm
Hi, Gerry.

Thanks for your explanation.
(REG.EXE has got an import/export command which can import/export a registry file (*.reg) as well)
Nevertheless, I agree, depending on what you wish to achieve, one of the available tools may be more appropriate than the others.

Karl
Back to Top
Gerry Hickman View Drop Down
Newbie
Newbie


Joined: 07 August 2006
Location: United Kingdom
Online Status: Offline
Posts: 14
Post Options Post Options   Quote Gerry Hickman Quote  Post ReplyReply Direct Link To This Post Posted: 04 February 2007 at 8:32am
Hi karl,

Yes, I forgot about Reg.exe; probably more suited to changing the odd key or value. I think Regini.exe and RegEdit.exe /s can be better when you need to change a lot of keys/values and I believe Regini.exe can also deal with permissions.

For machine registry hives (HKLM) on remote machines I tend to use WMI as this avoids needing an additional tool such as PsExec and you can perform other tasks at the same time.

For user registry hives (HKCU) there's also WshShell.RegRead() and RegWrite() which can be used within a Logon Script.
Back to Top
Karlchen View Drop Down
Senior Member
Senior Member
Avatar

Joined: 18 June 2005
Location: Germany
Online Status: Offline
Posts: 5121
Post Options Post Options   Quote Karlchen Quote  Post ReplyReply Direct Link To This Post Posted: 03 February 2007 at 10:15am
Originally posted by Gerry Hickman

Furthermore, RegEdit is a poor choice for remote registry manipulation; it's better to use a tool that's designed for pure command line operations and that does NOT require interaction with any desktop. I tend to use WMI for registry manipulation, but there's also a Microsoft tool called RegIni.exe

Agreed, "regedit.exe" is not really the best choice for sophisticated commandlines.

Anything wrong with using reg.exe instead? (I mean compared to WMI.)

Karl

Back to Top
Karlchen View Drop Down
Senior Member
Senior Member
Avatar

Joined: 18 June 2005
Location: Germany
Online Status: Offline
Posts: 5121
Post Options Post Options   Quote Karlchen Quote  Post ReplyReply Direct Link To This Post Posted: 03 February 2007 at 10:12am
Hi, jtwatsn.

In addition to Gerry's explanation, let me try to add some details:

psexec \\remotepc -i -d regedit /s c:\regupdate.reg

psexec will use the local user in order to authenticate to the \\remotepc.
regedit.exe will look for the file C:\regupdate.reg on the machine \\remotepc.
If either of the two fails the command will not work. (local user does not exist on \\remotepc, file regupdate.reg ist not located on C:\ on \\remotepc)

Note:
The command you try to launch remotely is regedit.exe, not just "regedit". So it is always a good idea to write the ".exe" as well.

---
psexec \\remotepc -i -d -c regedit /s c:\regupdate.reg

psexec will use the local user in order to authenticate to the \\remotepc. (see above)
psexec will try to copy a file named "regedit" to \\remotepc for execution. This is not what you want!
As explained above it is "regedit.exe", not just "regedit". But you do not wish to copy "regedit.exe" for executiion, but "regupdate.reg".

Limitation of pexec -c
The remote command to be executed remotely is "regedit.exe /s C:\regupdate.reg".
It consists of the executable name and 1 commandline argument.
Sadly enough the second part, regupdate.reg, needs to be transferred to \\remotepc before you can launch regedit.exe.
In such a case, the psexec option -c is of no use.

---
I will not comment on the next two commandlines, because by using a UNC path in your command you just added an extra layer of problems to the situation without solving any of the existing problems before.

---

The "messy" (Gerry's word) solution/workaround

From your local machine:
net use H: \\remotepc\C$ (replace H: by a drive letter not in use on your local machine)

copy C:\regupdate.reg H:\

psexec \\remotepc -i regedit.exe /s c:\regupdate.reg

Del H:\regupdate.reg
net use H: /dele


Hope this helps.
Karl
Back to Top
Gerry Hickman View Drop Down
Newbie
Newbie


Joined: 07 August 2006
Location: United Kingdom
Online Status: Offline
Posts: 14
Post Options Post Options   Quote Gerry Hickman Quote  Post ReplyReply Direct Link To This Post Posted: 03 February 2007 at 8:20am
Hi,

In general, if you write "C:\SomeFile.ext" you will have to ensure that file exists on the C drive of the REMOTE machine! You are telling PsExec to exec the command on the remote machine, so obviously it won't be able to see the C drive of the local machine. One (messy) option is simply to copy the file to the remote machine first.

If you want to reference files stored on UNC paths, then you need to ensure the process running on the REMOTE machine has the correct permissions to access the UNC share. By default, PsExec uses impersonation, but you can also force it to use a specific domain account.

Furthermore, RegEdit is a poor choice for remote registry manipulation; it's better to use a tool that's designed for pure command line operations and that does NOT require interaction with any desktop. I tend to use WMI for registry manipulation, but there's also a Microsoft tool called RegIni.exe
Back to Top
jtwatsn View Drop Down
Newbie
Newbie


Joined: 02 February 2007
Online Status: Offline
Posts: 2
Post Options Post Options   Quote jtwatsn Quote  Post ReplyReply Direct Link To This Post Posted: 02 February 2007 at 11:10am
Here is what I've tried:
 
psexec \\remotepc -i -d regedit /s c:\regupdate.reg
psexec \\remotepc -i -d -c regedit /s c:\regupdate.reg
psexec \\remotepc -i -d -c regedit /s \\localpc\folder\regupdate.reg
 
I've even used -e instead of -i and I get the following on the remotepc:
Cannot import <path to file>. Error opening the file. There may be a disk or file system error.
 
I can run the regupdate.reg file directly on the target machine and I can browse to the UNC and run it.  Any ideas???
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down