# HOWTO edit HKEY\_CURRENT\_USER that's not the ansible user?

**URL:** <https://forum.ansible.com/t/howto-edit-hkey-current-user-thats-not-the-ansible-user/24751>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [June 16, 2017, 10:27pm UTC](https://forum.ansible.com/t/howto-edit-hkey-current-user-thats-not-the-ansible-user/24751 "2017-06-16T22:27:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bob](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bob/32/9260_2.png) [@bob](https://forum.ansible.com/u/bob)\
**Post date:** [June 16, 2017, 10:27pm UTC](https://forum.ansible.com/t/howto-edit-hkey-current-user-thats-not-the-ansible-user/24751/1 "2017-06-16T22:27:46Z")

</div>

I need to make edits to HKEY\_CURRENT\_USER of a different user then the ansible\_user.

How do I do that?

Any edits I make with win\_regmerge are made to the ansible\_user’s registry.

I tried become\_method: runas with become\_user: but that throws a warning and error.

[WARNING]: The Windows ‘runas’ become method is experimental, and may change significantly in future Ansible releases.

FAILED! =\> {“failed”: true, “msg”: “The ‘runas’ become method requires a password (specify with the ‘-K’ CLI arg or the ‘ansible\_become\_password’ variable)”}

I come from a linux/unix background so I thought runas would be like sudo would let me run the command as the become\_user but I guess runas is a little different.

Any help?

Thanks.

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [June 16, 2017, 11:47pm UTC](https://forum.ansible.com/t/howto-edit-hkey-current-user-thats-not-the-ansible-user/24751/2 "2017-06-16T23:47:26Z")

</div>

Hey

Windows unfortunately doesn’t have the concept of sudo like unix so to be able to run a process as another user you need to set the password as well as the username. Going by the error message you need to set ‘ansible\_become\_password’ to the password of the account you are wanting to run as. I haven’t played around with runas unfortunately so I can’t give you any more info.

Another option if you really want to go the route is using the ‘HKEY\_USERS’ key. The entry for ‘HKEY\_CURRENT\_USER’ in ‘HKEY\_USERS’ is located in this key under the SID (S-_-_-_-_-\*). So using the ‘user’ account as an example I can use this command to get the SID of the Administrator account

`$AdObj = New-Object System.Security.Principal.NTAccount('user') $strSID = $AdObj.Translate([System.Security.Principal.SecurityIdentifier]) $strSID.Value`

It will return the value

`S-1-5-21-2607664055-1112657780-300677247-500`

So the ‘HKEY\_CURRENT\_USER’ when running as ‘user’ can also be accessed at ‘HKEY\_USERS\S-1-5-21-2607664055-1112657780-300677247-500’.

Hope this helps in some way.

Thanks

Jordan

---

<div class="post-metadata">

**Author:** ![Bob\_Tanner](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Bob\_Tanner](https://forum.ansible.com/u/Bob_Tanner)\
**Post date:** [June 17, 2017, 5:57am UTC](https://forum.ansible.com/t/howto-edit-hkey-current-user-thats-not-the-ansible-user/24751/3 "2017-06-17T05:57:16Z")

</div>

> So the ‘HKEY\_CURRENT\_USER’ when running as ‘user’ can also be accessed at ‘HKEY\_USERS\S-1-5-21-2607664055-1112657780-300677247-500’.

I put the edits into the HKEY\_USERS\S-_-_-_-_-\* should they show up in the HKEY\_CURRENT\_USER when I’m logged in as that user?

It doesn’t look like it.

---

<div class="post-metadata">

**Author:** ![Bob\_Tanner](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Bob\_Tanner](https://forum.ansible.com/u/Bob_Tanner)\
**Post date:** [June 17, 2017, 6:42am UTC](https://forum.ansible.com/t/howto-edit-hkey-current-user-thats-not-the-ansible-user/24751/4 "2017-06-17T06:42:09Z")

</div>

[http://bit.ly/2tcKt3L](http://bit.ly/2tcKt3L)

Difference between HKEY\_Current\_User and HKEY\_USERs?

Suggests edits to HKEY\_USERS should be reflected in HKEY\_CURRENT\_USER
