How do I add Registry entry under HKEY_USERS\ for the current user


  1. Posts : 4
    Windows 7 Professional x86
       #1

    How do I add Registry entry under HKEY_USERS\ for the current user


    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!
      My Computer


  2. Posts : 2,963
    Windows 7 Professional SP1 64-bit
       #2

    Maybe you should give us a more detailed explanation of exactly what you are trying to do. Your question does not tell us much and without understanding exactly what you are doing, it will be more difficult to help.
      My Computer


  3. Posts : 934
    Windows 8.1 ; Windows 7 x86 (Dec2008-Jan2013)
       #3

    Let's say your current user name is MARK.

    Then you copy the following code
    Code:
    $objUser = New-Object System.Security.Principal.NTAccount("MARK") 
    $strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier]) 
    $strSID.Value
    open Windows PowerShell and right click in it's command window (should work as Paste command), then hit Enter.
    It will show you SID for user named Mark.

    Then you need to edit reg file in Notepad and substitute SID with a correct one (You can export reg file from Regedit if required and then import back edited one).

    BUT first BACKUP your data+registry!

    It works other way around too. You can find a username by SID:
    Code:
    $objSID = New-Object System.Security.Principal.SecurityIdentifier ` 
        ("S-1-5-21-1454471165-1004335555-1606985555-5555") 
    $objUser = $objSID.Translate( [System.Security.Principal.NTAccount]) 
    $objUser.Value
      My Computer


  4. Posts : 4
    Windows 7 Professional x86
    Thread Starter
       #4

    Petey7 said:
    Maybe you should give us a more detailed explanation of exactly what you are trying to do. Your question does not tell us much and without understanding exactly what you are doing, it will be more difficult to help.

    Sorry for giving such a short description of my problem.

    So here's the scenario, were are going to deploy Fortinet SSL VPN client to all our laptops here in our company. We have no problem in installing the Fortinet client, the problem is we have to pre-configured the settings in it. I found out that the settings are stored in the registry, so what I did is I configured my Fortinet client then exported the registry keys of the settings. I tried logging in into another computer with fortinet client but no configurations yet. I merged the .reg file I imported and I was able to pre-configured the fortinet client. The problem here is the registry keys I imported has my SID and when I imported it using a different account, it would not take effect or even have errors because I using a different SID.

    Here's the key I imported:

    [HKEY_USERS\S-1-5-21-3810145928-4034201778-1548147441-1606\Software\Fortinet\SslvpnClient\Tunnels]

    My objective here is how can I change the SID(those in red) to the current SID of the user when I merge the .reg file I exported. Would it be possible?

    Hope this is clear enough.

    Thanks!
      My Computer


  5. Posts : 934
    Windows 8.1 ; Windows 7 x86 (Dec2008-Jan2013)
       #5

    From your user you should have exported the key
    HKEY_CURRENT_USER\Software\Fortinet\SslvpnClient\Tunnels
    which would be "virtual" key of current logged user (it has no data, it just links to current logged user).

    If you export that thread from your computer, you can import in at any computer without messing with SIDs.

    So, make another master reg file or edit existing replacing
    HKEY_USERS\S-1-5-21-3810145928-4034201778-1548147441-1606\Software\Fortinet\SslvpnClient\Tunnels
    with
    HKEY_CURRENT_USER\Software\Fortinet\SslvpnClient\Tunnels
      My Computer


  6. Posts : 4
    Windows 7 Professional x86
    Thread Starter
       #6

    Neutron16 said:
    From your user you should have exported the key
    HKEY_CURRENT_USER\Software\Fortinet\SslvpnClient\Tunnels
    which would be "virtual" key of current logged user (it has no data, it just links to current logged user).

    If you export that thread from your computer, you can import in at any computer without messing with SIDs.

    So, make another master reg file or edit existing replacing
    HKEY_USERS\S-1-5-21-3810145928-4034201778-1548147441-1606\Software\Fortinet\SslvpnClient\Tunnels
    with
    HKEY_CURRENT_USER\Software\Fortinet\SslvpnClient\Tunnels

    Hi,

    yes, I also thought of it, but per checking with the registry, there is no [HKEY_USERS\Software\Fortinet\SslvpnClient\Tunnels], only [HKEY_USERS\Software\Fortinet\SslvpnClient]. How can I create a new key for Tunnels?
      My Computer


  7. Posts : 4
    Windows 7 Professional x86
    Thread Starter
       #7

    Hi,

    I was able to find the commandline on adding registry keys for the current users through DOS.

    Here's the command line:
    reg add HKEY_CURRENT_USER\Software\Fortinet\SslvpnClient\Tunnels

    Problem now is ordinary users are not allowed to edit the Registry so I have to open an Elevated Command Prompt through run As, then run the commandline. It is successful, but it will add the configuration for the Administrator user that I used to open the command prompt.

    How can I apply the change for all users? Is it possible?
      My Computer


  8. Posts : 2
    x64 W7 HomePremium
       #8

    markceliz09 said:
    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.
      My Computer


  9. Posts : 2
    x64 W7 HomePremium
       #9

    @Neutron16

    This seems like a good answer, if you like using PowerShell, which I did for awhile... problem is it's too complex and limiting due to the gross shortage of helpfiles for the average user who tries to use it. So it seemed to me that no matter how good I got at using it, there was always some insurmountable 20 mile high brick wall I ran into when using it. & asking other's to help is often inconvenient.

    For example, say you retrieve the SID with PowerShell, now the only option is to copy it somewhere. Or ask for help with the next step, which may or may not be the most effective attempt at using the info. Which may lead to more queries. & on & on.

    But I must admit, nice answer, good work, this is an awesome use of PowerShell:

    Neutron16 said:
    Let's say your current user name is MARK.

    Then you copy the following code
    Code:
    $objUser = New-Object System.Security.Principal.NTAccount("MARK") 
    $strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier]) 
    $strSID.Value
    open Windows PowerShell and right click in it's command window (should work as Paste command), then hit Enter.
    It will show you SID for user named Mark.

    Then you need to edit reg file in Notepad and substitute SID with a correct one (You can export reg file from Regedit if required and then import back edited one).

    BUT first BACKUP your data+registry!

    It works other way around too. You can find a username by SID:
    Code:
    $objSID = New-Object System.Security.Principal.SecurityIdentifier ` 
        ("S-1-5-21-1454471165-1004335555-1606985555-5555") 
    $objUser = $objSID.Translate( [System.Security.Principal.NTAccount]) 
    $objUser.Value
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 09:51.
Find Us