Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Update a registry value to every user hive

Posted on 2016-09-01
15
Medium Priority
?
113 Views
Last Modified: 2016-09-13
Hi ..
I need to modify registry key below for the current  user and all the users (S-#-#-##) in the windows registry, if the key exists.
How can I automate this process using  a script.
Type is REG_SZ.

HKEY_CURRENT_USER\Software\x2FTP\ControlBase ]
"Flags"="26"  

Thank you for your help.
0
Comment
Question by:NetRock6
15 Comments
 
LVL 25

Expert Comment

by:NVIT
ID: 41780716
You can put in the User gpo. Or, in the user's logon script, which would call the REG IMPORT thefile.reg
0
 

Author Comment

by:NetRock6
ID: 41780731
Thanks for your reply.
I know how to apply it.
I need to know how to enumerate through all the users under HKEY_USERS to update all users at once,
by running a script.

Thank you for your help
0
 
LVL 60

Expert Comment

by:Julian Hansen
ID: 41781372
How do you plan to run that script though? Is this for a single workstation / server used by multiple users or in a roaming profile environment

The user Registry HIVE is loaded at login and then unloaded again when they logoff.

Consider the situation where a user logs onto machine 1 changes something logs off then logs onto machine 2 - now assuming the profile persisted - which one do you modify. The next logon will overwrite the change.

If you have a roaming setup you would need to iterate through your useraccounts, find their roaming profile store, load their registry .DAT into the registry, then apply the change - possible but a lot of work.

Why not use the logon script / GPO as suggested above?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:NetRock6
ID: 41781585
I understand your concern. I am not the IT Dept. and to get the IT Dept's cooperation will take sometimes base on their regulation and process. I do not wish to go into more details here.
So, The only way is the long way, in this case....
0
 
LVL 60

Expert Comment

by:Julian Hansen
ID: 41781626
No there are two ways
1. The easy way - by logon script / GPO
2. Writing a script that pulls the user account list from AD, loops through this getting profile locations, loading profile into registry, applying change, unloading registry

Bear in mind with item 2 you will need to run this when you know users won't be logged on - otherwise you will load their profile - make the change - they logout and overwrite the change.

Logon script / GPO means it will be applied correctly and saved correctly.
0
 

Author Comment

by:NetRock6
ID: 41786189
The only way for me is to log on to run the script to detect all user accounts that have been logon to update the registry value. Also, change the default profile.
0
 
LVL 60

Expert Comment

by:Julian Hansen
ID: 41786272
I don't understand your comment?

To update a user Registry Setting the user Registry has to be loaded on the workstation you are running the script. In most production environments user profiles are configured to unload on logoff to save space. Users can also potentially be logged on to more than one session so trying to update all user Registry values in one go - in my view is not practical.
0
 

Author Comment

by:NetRock6
ID: 41788349
I will run the script at the maintenance time on each workstation, so no users are logged on.
Then, the script would need to query the usernames who are already logged on to the WS, and then upload the registry to update the entry.
0
 
LVL 60

Expert Comment

by:Julian Hansen
ID: 41788424
I will run the script at the maintenance time on each workstation, so no users are logged on.
If there are no users logged on then how can you guarantee their profiles will be loaded?
0
 

Author Comment

by:NetRock6
ID: 41789576
So far, none of the comments were able to help ....!!

I need to update a registry key .... that can be done by hive registry!!
No need for the users to be logged on!! :)
0
 
LVL 60

Expert Comment

by:Julian Hansen
ID: 41789670
In your opening question you said you need to update this key
HKEY_CURRENT_USER\Software\x2FTP\ControlBase ]

Open in new window

HKEY_CURRENT_USER is in the user's profile - it only exists when a user is logged on. When a user logs off - if the policy on the machine is to unload the profile (which is pretty standard) the user profile is removed. Either way after logoff the HKEY_CURRENT_USER hive dissappears.

Here is how it works.
User profiles comprise two things
1. Registry Settings
2. Files

Registry settings are stored in a file called NTUSER.DAT which sits in the root of the user profile.

When a user logs on the winlogon process finds this file and loads in into the Registry under the HKEY_CURRENT_USER hive.

When the user loggs off this HIVE is unloaded.

If the policy on the machine is to unload user profiles then all local copies of the profile are removed.
If the policy is not to unload profiles then a copy of the registry may be available but it will be under the HKEY_USERS hive with a key equal to the SID of the user's account.

So, in answer to your question - for the key you want to update - the user must be logged on.
0
 

Author Comment

by:NetRock6
ID: 41795115
The User does not need to be logged on in order to change/update/add registry keys....
As, i said before .. none of the comments above seem to help out....
0
 
LVL 60

Expert Comment

by:Julian Hansen
ID: 41795511
The User does not need to be logged on in order to change/update/add registry keys....
Ok I am going to try this one last time
HKEY_CURRENT_USER\Software\x2FTP\ControlBase ]

Open in new window

Hive: HKEY_CURRENT_USER
Which implies user profile
Profiles are loaded into HKEY_CURRENT_USER when the user is logged on.
Please explain how you are going to access the HKEY_CURRENT_USER key of user who is not logged on?
0
 
LVL 85

Accepted Solution

by:
oBdA earned 2000 total points
ID: 41795719
Run this on the workstation(s) in question.
This will create an entry in the Run key, which in turn will set the required value as soon as a user logs on.
reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /f /v x2FTP /t REG_SZ /d "reg.exe add HKCU\Software\x2FTP\ControlBase /f /v Flags /t REG_SZ /d 26"

Open in new window

0
 

Author Closing Comment

by:NetRock6
ID: 41796995
Thank YOU...!
Keep up the Great Work.... :)!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
Measuring Server's processing rate with a simple powershell command. The differences in processing rate also was recorded in different use-cases, when a server in free and busy states.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question