Solved

Reg Load batch file problem

Posted on 2009-06-30
10
1,923 Views
Last Modified: 2012-05-09
Hey
I am having a problem creating a batch file that loads an NTUSER.dat file into HKU in the registry, then exports a key from the NTUSER.dat file into a .reg file.
Can someone have a look at the code below and tell me where I am going wrong?
I plan to push it out using our software delivery program, but I need to get the batch file working first. We are running a windows XP based environment.
Thanks

REG LOAD HKU\NTUSER "c:\Documents and Settings\%username\ntuser.dat"
 

REG EXPORT HKU\NTUSER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging SubSystem\Profiles" "C:\Documents and Settings\%username%\Desktop\trial.reg"
 

REG UNLOAD HKU\NTUSER

Open in new window

0
Comment
Question by:PremCab
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 66

Expert Comment

by:johnb6767
ID: 24751670
REG LOAD HKLM\NTUSER "c:\Documents and Settings\%username\ntuser.dat"
 
REG EXPORT HKLM\NTUSER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging SubSystem\Profiles" "C:\Documents and Settings\%username%\Desktop\trial.reg"
 
REG UNLOAD HKLM\NTUSER
0
 

Author Comment

by:PremCab
ID: 24751684
Sorry Does the same thing as HKU. I have tried both options. It seems as there is something wrong with the REG LOAD line because when I place a pause command after it, it doesn't pause. A command prompt screen just flashes on the screen
0
 
LVL 19

Expert Comment

by:deroode
ID: 24752277
When you run this batch %username will be the name of the logged in user. Because this user is logged in his profile is in use, and cannot be loaded again. You will find his profile in HKEY_Current_user

REG EXPORT HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging SubSystem\Profiles" "C:\Documents and Settings\%username%\Desktop\trial.reg"
0
 
LVL 21

Expert Comment

by:AmazingTech
ID: 24752462
Your software delivery program will probably run with the different userid other than the actual user. You might want to put this into your AD logon script or GPO User Logon Script.

I don't like using

"C:\Documents and Settings\%username%\Desktop\trial.reg" because a user could have a stuck profile and the actual folder might be something like %username%.%userdomain% or %username%.001 or %username%.002
REG EXPORT HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging SubSystem\Profiles" "%userprofile%\Desktop\trial.reg"

Open in new window

0
 
LVL 21

Expert Comment

by:AmazingTech
ID: 24752465
Opps the export will need quotes too.
REG EXPORT "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging SubSystem\Profiles" "%userprofile%\Desktop\trial.reg"

Open in new window

0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 19

Accepted Solution

by:
deroode earned 500 total points
ID: 24752550
Amazingtech,

Even if the software delivery program runs as a different user it is impossible to load the user hive of the currently logged in user again.
You will however find all loaded user hives under HKU. A problem is of how to find out which profile belongs to whom...
0
 
LVL 66

Expert Comment

by:johnb6767
ID: 24757225
Cant believe I missed the nd qoute on %username...    

Any update?
0
 

Author Comment

by:PremCab
ID: 24759266
Thanks for all your help.

We may end up running it via login scripts, because of deroode's comment. I didn't even click that it wouldn't work because the user is logged in still. If only the keys under HKU were easy to distiguish between without actually opening the key.

Thank you again for all your help
0
 

Author Closing Comment

by:PremCab
ID: 31598611
Thanks for pointing out the obvious, which I was yet to realise.

It's always the most obvious and simplist answer which you tend to skim over.
0
 
LVL 21

Expert Comment

by:AmazingTech
ID: 24760929
derode:

I do agree with you hku is the only way to find someone else's hive when they are logged in. Typically something like SMS will run even if a user is not logged on.

BTW:

HKU\{SID}\Software\Microsoft\Windows\CurrentVersion\Explorer
Logon User Name

Is what I use to find out who this particular SID belongs to.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now