Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Update a registry value to every user hive

Posted on 2016-09-01
15
Medium Priority
?
103 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 58

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
10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

 

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 58

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 58

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 58

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 58

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 58

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
While working, an annoying popup showing below will come and we cannot cancel or close it form the screen. The error message will come again and again.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

719 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