Solved

Update a registry value to every user hive

Posted on 2016-09-01
15
72 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 23

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 52

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
 

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 52

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 52

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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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 52

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 52

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 52

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 83

Accepted Solution

by:
oBdA earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now