Solved

Reg Load batch file problem

Posted on 2009-06-30
10
1,918 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

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…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

757 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