'Why there is no entry in HKU for user created by Salt

I have a user created by Salt user.present state. Details returned by user.info:

----------
account_disabled:
    False
account_locked:
    False
active:
    True
comment:
description:
disallow_change_password:
    False
expiration_date:
    2106-02-07 07:28:15
expired:
    False
failed_logon_attempts:
    0
fullname:
    Student
gid:
groups:
    - Użytkownicy
home:
    Student
homedrive:
    C:
last_logon:
    2022-02-21 21:01:13
logonscript:
name:
    Student
passwd:
    None
password_changed:
    2022-02-21 21:01:07
password_never_expires:
    False
profile:
    Student
successful_logon_attempts:
    2
uid:
    S-1-5-21-3207633127-2685365797-3805984769-1043

My goal is to add some registry entries for the user. I tried using reg.present state to add a key with the follwing error:

      ID: HKEY_USERS\S-1-5-21-3207633127-2685365797-3805984769-1043\Software\Microsoft\Windows\CurrentVersion\Policies\Uninstall!NoAddRemovePrograms
Function: reg.present
  Result: False
 Comment: Failed to add None to HKEY_USERS\S-1-5-21-3207633127-2685365797-3805984769-1043\Software\Microsoft\Windows\CurrentVersion\Policies\Uninstall!NoAddRemovePrograms
 Started: 21:14:39.581549
Duration: 0.0 ms
 Changes: 

When I run reg.list_keys HKU, I don't see the S-1-5-21-3207633127-2685365797-3805984769-1043 listed above:

- .DEFAULT
- S-1-5-19
- S-1-5-20
- S-1-5-21-3207633127-2685365797-3805984769-1001
- S-1-5-21-3207633127-2685365797-3805984769-1001_Classes
- S-1-5-18

I have logged in as the user to make sure the profile is fully created. No HKU entry even then. Why is the entry not getting created?

BTW: I've verified using regedit if the info returned by Salt is correct and it is. I do not see the user id using regedit either.



Solution 1:[1]

HKU is a pain to work with. and normally shouldn't be edited directly. so the only users that can show up there are logged in users.

I'm not sure why the user is not showing up when the user is logged in however. that sounds like a windows issue.

You can force load users into HKU see https://www.pdq.com/blog/modify-the-registry-of-another-user/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 whytewolf