Solved

Update a registry value to every user hive

Posted on 2016-09-01
15
61 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 51

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 51

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 51

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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 51

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 51

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 51

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: Lee
Windows 7 Ultimate and Enterprise (and 2008 R2) introduced a new feature you may not be aware of - Boot from VHD.   Boot from VHD (or what Microsoft refers to asNative Boot allows you to install Windows to a VHD (Virtual Hard Disk) file that is t…
If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

758 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

22 Experts available now in Live!

Get 1:1 Help Now