Search code examples
windowsregistry

Changing other user's registry who hasn't logged in


I'm working on an easy way to provision in windows 10 and I'd like to be able to login as an admin then modify a non-admin's HKCU keys so that when they first login the settings will be set. I think I can edit through the HKEY_USERS node in the registry, but this non-admin's node doesn't exist there until they login. Is there some way to force the creation of this node? Or someway to edit the HKCU keys I want to modify? I found I can run Get-WmiObject win32_useraccount and get the non-admin users SID if that helps. Thanks!

There's a related post on stack overflow where (from the comments)it looks like they got it working using PSExec and LogonUI.exe, but I can't find any documentation on using LogonUI force creation of a user's HKCU hive.


Solution

  • What I ended up doing is loading the default ntuser.dat file. Then when the user logs in they have the correct HKCU keys. It's not as targeted since it effects all users rather than just the one I want. Example

    REG LOAD HKU\ZZZ "C:\Users\Default\NTUSER.DAT"
    REG ADD HKU\ZZZ\Software\Microsoft\Windows\CurrentVersion\ImmersiveShell
    REG ADD HKU\ZZZ\Software\Microsoft\Windows\CurrentVersion\ImmersiveShell /V TabletMode /T REG_dWORD /D 1 /F
    REG UNLOAD HKU\ZZZ