Hi,
How can I add a registry entry under HKEY_USERS for the current user? I already have the registry entry imported from my account, but my problem is it won't work with other accounts because we have different SID for HKEY_USERS. Please help me on this.
Thanks!
Your question becomes clear when the one answering has experienced the problem themselves.
None of the answers given helped me when I had the same problem and desired the same solution you did.
You may have found the answer somewhere but I wanted to post something usable here to help the next person who experiences this.
Using a small program that is free do download, called AutoHotKey you can retrieve the SID (
Security Identifier) of the currently logged on user. I made a script that can achieve this... or it can be retrieved manually if you're not in any hurry.
Here's my script, just install AutoHotKey, past this into a text file and change the extension to .ahk rather than .txt.
; @@@@@@@@@@@@@@@@@@@@
;The following will retrieve the current user's SID, when ran as a AutoHotKey Script.
;Or you can manually navigate the registry to find it.
; Lines preceded by a semi-colon (

are seen as comments and are not ran inside a AutoHotKey script
{
SetBatchLines -1
#SingleInstance Force
; This reads the specific location in the registry
Loop, HKLM, SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList, 1, 1
{
; Skips entries without a modification time (the SID has a mod time)
If (A_LoopRegTimeModified = "")
Continue
; This is the entry we need
RegRead, UserInfo, HKLM, SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\%A_LoopRegName%, ProfileImagePath
; The following ensures this is the entry we need
StringLeft, IsUser, UserInfo, 8
Comp = %SystemDrive%\Users
If (IsUser = Comp)
{
SID := A_LoopRegName
break
}
}
Clipboard := SID ; This appends the current user's SID to the clipboard so it can be pasted wherever
MsgBox, % SID ; this gives a visual message showing the current user's SID
ExitApp ; close this autohotkey script
}
; @@@@@@@@@@@@@@@@@@@@
; End of AutoHotKey Script, don't copy below this line.
So without much skill you can easily use this to copy & past the SID anywhere you like.
Or, with appropriate AutoHotKey skills you can use this to do a variety of things, such as :
1. Use AutoHotKey to modify or write a .reg, .cmd, .bat, or other file.
2. Use AutoHotKey to read, write, delete, or open regedit to a desired registry entry / address.
See AutoHotKey help file, search under RegWrite, RegRead, RegDelete, Loop (Registry).
Slightly More complex :
To open regedit to desired registry address search online for AutoHotKey script called "RegJump"
which writes a value to HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit, LastKey,
which is where regedit will open to when closed and reopened, which the script does for you.
And to modify values in other files use a file reading command and "stringreplace" along with a file append command. You may wish to have a backup of the file just in case.
Hope this helps.