Link to home
Start Free TrialLog in
Avatar of PremCab
PremCabFlag for Australia

asked on

Reg Load batch file problem

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

Avatar of johnb6767
johnb6767
Flag of United States of America image

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
Avatar of PremCab

ASKER

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
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"
Avatar of AmazingTech
AmazingTech

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

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

ASKER CERTIFIED SOLUTION
Avatar of deroode
deroode
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Cant believe I missed the nd qoute on %username...    

Any update?
Avatar of PremCab

ASKER

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
Avatar of PremCab

ASKER

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.
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.