Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Reg Load batch file problem

Posted on 2009-06-30
10
Medium Priority
?
1,938 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
LVL 19

Accepted Solution

by:
deroode earned 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

We have adopted the strategy to use Computers in Student Labs as the bulletin boards. The same target can be achieved by using a Login Notice feature in Group policy but it’s not as attractive as graphical wallpapers with message which grabs the att…
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Loops Section Overview
Suggested Courses

963 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