2

What i want: Load another users registry hive (HKCU aka NTUSER.DAT located in %UserProfile%\UserName on local machine).

^ This works just fine. Inluding the unload command.

The problem is with the reg /import command that seems to import things only to currently logged on users HKCU. I even tried changing the .reg files i want to import, manually to point to the location where the hive is located (in my case HKU/UserName). But even then when i doubleclicked the .reg file it's settings were still imported into my own HKCU.

I also looked into creating the nessesary keys with PowerShell but some of the keys and data to be created is massive (700+ subkeys) so it's not really an option.

Any ideas on how I can do this?

Similar topic on TechNet forums

James Mertz
  • 26,224
  • 41
  • 111
  • 163
TMRW
  • 1,054
  • 4
  • 17
  • 28
  • 1
    Try using Runas to load the user profile and run in the context of that user. Something like `runas /user domain\userToImportHiveFor "regedit /import regfile.reg"` perhaps? – Ƭᴇcʜιᴇ007 Jan 27 '14 at 16:22

1 Answers1

0

This works for me

runas /u:tester "cmd.exe /k reg import c:\temp\test.reg"

test.reg:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\testkey]

Once you runas something as another user you will see it's registry appear under HKEY_USERS and the value is imported there.

Vitas
  • 881
  • 4
  • 15
  • 30
  • Ok it almost worked after: I made sure Secondary Logon service was running (it was manual but stopped), i escaped quotation marks by backslash \ but unfortunately for runas to work the other user MUST have a password set and it CANT be a blank one either. So that's a major problem because i dont have (and i dont want to) have password set for the second user. The command itself was: Runas /profile /Env /user:UserName "reg /import \"c:\temp\test.reg\"" after wich i got: Enter the password for UserName: – TMRW Jan 29 '14 at 00:09
  • 1
    http://superuser.com/questions/342680/enable-password-blank-run-as-on-home-premium this seems to help – Vitas Jan 29 '14 at 08:45
  • Indeed i was now able to execute the import with `Runas /savecred: /u:UserName "reg /import \"c:\temp\test.reg\""` – TMRW Jan 30 '14 at 08:03