Sysinternals Homepage
Forum Home Forum Home > Sysinternals Utilities > PsTools
  New Posts New Posts RSS Feed - Psexec running a Reg Import
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Psexec running a Reg Import

 Post Reply Post Reply
Author
Message
narbertb View Drop Down
Newbie
Newbie


Joined: 22 June 2009
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote narbertb Quote  Post ReplyReply Direct Link To This Post Topic: Psexec running a Reg Import
    Posted: 22 June 2009 at 5:08pm
Hey all,
 
I've tried psexec 1.94 and 1.95
 
This is what i've tried to run
psexec -i 0 \\ipaddress reg import c:\file.reg
or psexec \\ipaddress reg import c:\file.reg
I've also created a batch file that only contains
     reg import c:\file.reg
 
I watch a command prompt flash on the remote system
On the system where the command was issued, it comes back as exited with error code 0.
So it looks like it works for all 3 of the above commands.
 
Both systems DO NOT have admin rights.
When i double click on the file.reg file it imports just fine.
As does a running the Reg Import from a command prompt on the local system
So i don't think its a rights issue.
 
But in the end PSEXEC does import the registry key.
Any thoughts would be helpful.
 
Thanks for your time
 
Back to Top
molotov View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 04 October 2006
Status: Offline
Points: 17516
Post Options Post Options   Thanks (0) Thanks(0)   Quote molotov Quote  Post ReplyReply Direct Link To This Post Posted: 22 June 2009 at 6:55pm
Hi narbertb,

As you are using -i 0 in the command-line, you are telling PsExec to start the program so that it interacts with the desktop on the remote system.  That is why the command-prompt flashes on the remote system.

I do not expect that this command will cause anything to display on the remote system...
  psexec \\ipaddress reg import c:\file.reg
Daily affirmation:
net helpmsg 4006
Back to Top
narbertb View Drop Down
Newbie
Newbie


Joined: 22 June 2009
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote narbertb Quote  Post ReplyReply Direct Link To This Post Posted: 22 June 2009 at 7:16pm
Hey Molotov...
 
I tried running the command 3 different ways..
1. with the -i 0 switch
2. without the switch
and 3. calling the batch file.
 
All three do the same thing.  It comes back with the error 0 like it worked.
 
I did some playing and was able to run
psexec -i 0 \\ipaddress net localgroup localcomputername\tempuser /add
and that worked fine
 
and a simple command like
psexec -i 0 \\ipaddress notepad.exe
works just fine.
 
Is it possible there is a bug calling REG?
I've recreated the file.reg file just to make sure that i had a good file.
And i can import it locally by double clicking or from a command prompt doing a reg import locally.


Edited by narbertb - 22 June 2009 at 7:20pm
Back to Top
molotov View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 04 October 2006
Status: Offline
Points: 17516
Post Options Post Options   Thanks (0) Thanks(0)   Quote molotov Quote  Post ReplyReply Direct Link To This Post Posted: 22 June 2009 at 7:40pm
It is not clear what the problem is, then.  PsExec, when invoked without the -d param, will return the exit code of the process that was launched.  An error / exit code if 0 is normal for success, but the meaning of the code is specific to the app that is invoked...
Daily affirmation:
net helpmsg 4006
Back to Top
narbertb View Drop Down
Newbie
Newbie


Joined: 22 June 2009
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote narbertb Quote  Post ReplyReply Direct Link To This Post Posted: 22 June 2009 at 8:57pm
I have my answer... not sure why its happening... but i can recreate it.
 
The reg key that i'm exporting is
HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem
 
This key holds the outlook profile info and makes it very easy to setup a new system.
 
The user i was logged in as was a generic account.  And because that generic account didn't have an email account associated with it, i used my email account and told outlook to prompt for security credentials when i set it up.  Exported the key.  Deleted the outlook profile.  Tried psexec and nothing.  It didn't come back.
 
So i logged out as the generic account and logged in as my account, and there it was.  Outlook fired right up with my settings.  Still logged in as myself, i deleted the outlook profile and tried psexec again.  And it worked fine.  Good to know that psexec wasn't the culprit but the reg key doing something that i didn't expect it to do.
 
Thanks for the help
 
Back to Top
SvenBomwollen View Drop Down
Senior Member
Senior Member


Joined: 29 August 2008
Location: Germany
Status: Offline
Points: 1630
Post Options Post Options   Thanks (0) Thanks(0)   Quote SvenBomwollen Quote  Post ReplyReply Direct Link To This Post Posted: 22 June 2009 at 10:37pm
Hello, narbertb.

The tricky thing about importing registry keys into HKCU is that HKCU means "Hive Key Current User". The registry key(s) will be imported into the NTUSER.DAT of the user running the "reg import" command.

If user A exports HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem to a file, HKCU refers to user A. His registry keys will be exported.

If user B imports user A's export into HKCU, then HKCU refers to user B. So user A's registry keys will be imported into user B's profile (ntuser.dat).

This may not be what you expect and what you want to do in all cases.

Kind regards,
SvenBomwollen




Edited by SvenBomwollen - 22 June 2009 at 10:40pm
Back to Top
narbertb View Drop Down
Newbie
Newbie


Joined: 22 June 2009
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote narbertb Quote  Post ReplyReply Direct Link To This Post Posted: 23 June 2009 at 6:16pm
And that is why this was so odd.
 
I was logged into the system as user TEST.  No admin rights, just a default user.
This account didn't have an email account associated with it.
So i set up an outlook profile pointing to my user (told outlook to prompt for credentials)
Now mind you... i haven't logged into this system as myself.
So now an outlook profile is created.  I close out of outlook, and do a reg export of the messaging key.
Delete the outlook profile from the mail icon in control panel.
Then i run PSEXEC to import the key.
PSEXEC runs with no errors, but the outlook profile doesn't get recreated.
 
Here is the weird part.
I log in as myself for the very first time on this system.
Fire open outlook, and there are my settings from the export.
 
My test scenario won't really matter in what i'm doing, but if i come across one of my users with multiple outlook profiles it will.  But i'll deal with that when it happens.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down