Solved

Reg Load batch file problem

Posted on 2009-06-30
10
1,934 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Can I legally transfer my OEM version of Windows to another PC?  (AKA - Can I put a new systemboard in my OEM PC?) Few of us are both IT and legal experts but we all have our own views of Microsoft's licensing rules and how they apply.  There are…
If your system is showing symptoms of browser hijacks or 'google search redirects' check out my other article (http://rdsrc.us/u3GP7A) first and run the tool TDSSKiller (http://rdsrc.us/GDBBs4) to get rid of the infection. Once done, and if the …
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

636 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