Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


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

15 Dec 2011   #1
markceliz09

Windows 7 Professional x86
 
 
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 System SpecsSystem Spec
.
15 Dec 2011   #2
Petey7

Windows 7 Professional SP1 64-bit
 
 

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 System SpecsSystem Spec
15 Dec 2011   #3
Neutron16

Windows 8.1 ; Windows 7 x86 (Dec2008-Jan2013)
 
 

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 System SpecsSystem Spec
.

16 Dec 2011   #4
markceliz09

Windows 7 Professional x86
 
 

Quote   Quote: Originally Posted by Petey7 View Post
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 System SpecsSystem Spec
16 Dec 2011   #5
Neutron16

Windows 8.1 ; Windows 7 x86 (Dec2008-Jan2013)
 
 

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 System SpecsSystem Spec
16 Dec 2011   #6
markceliz09

Windows 7 Professional x86
 
 

Quote   Quote: Originally Posted by Neutron16 View Post
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 System SpecsSystem Spec
16 Dec 2011   #7
markceliz09

Windows 7 Professional x86
 
 

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 System SpecsSystem Spec
06 Aug 2015   #8
VIITweaker

x64 W7 HomePremium
 
 

Quote   Quote: Originally Posted by markceliz09 View Post
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 System SpecsSystem Spec
06 Aug 2015   #9
VIITweaker

x64 W7 HomePremium
 
 

@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:

Quote   Quote: Originally Posted by Neutron16 View Post
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 System SpecsSystem Spec
Reply

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




Thread Tools




Similar help and support threads
Thread Forum
Can you copy a WinXP Pro registry entry into Win 7 registry
Hello, Background: 1. I have a program I use always, I have the install disks and can install it on Win 7 Pro x64. It is a 32 bit program. However, this program had a critical patch issued as a download way back when and this patch cannot be installed on the 7 system, because the installer is...
General Discussion
An entry in registry missing
I want gain an access to com ports and require changed in registry entry of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PNP0501 but it seems the folder is not there. I have tried regcleaner and reg fix did not help. thanks
Drivers
Registry Entry to delete specific User Profile entries
I work for a University as a Lab Manager where we have over 300 computers running Domain Profiles. We have begun updating from XP to 7 and started to notice TEMP profiles being created. I have figured out how to resolve the issue by going to the registry ...
General Discussion
Cannot delete Registry entry
After trying to recover from severe malware infection, I ran Spybot S&D. It removed several Registry entries but one it could not. I tried manually but it could not be removed. It is located at Hkey-users\S-1-5-21-200258984-2800820833-1255355968\Software\DataMngr. It has subdirectories "Files",...
System Security
User/SID doesn't appear in HKEY_USERS
Hi, I'm looking to add a key to a the HKEY_USERS hive through the reg command but when I run it I get an "invalid parameter" error. When I got to the HKEY_USERS hive I don't see the SID concerned however when I go to HKEY_LOCAL_MACHINE > SOFTWARE > MICROSOFT > WINDOWS NT > CurrentVersion >...
Performance & Maintenance
What is the strange registry entry and how can I delete it?
I have the following registry key that appears to do nothing but keeps re-creating itself: HKEY_CURRENT_USER\Software\Microsoft\WindowsNT\CurrentVersion\Winlogon This key contains a Shell value that points to an empty directory on my system: C:\Users\Birk\AppData\Local\bc53345c\X If I...
Software


Our Sites

Site Links

About Us

Find 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 11:13.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App