Solved

Update a registry value to every user hive

Posted on 2016-09-01
15
93 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 24

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 57

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
Technology Partners: 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 57

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 57

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 57

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 57

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 57

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 84

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
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…
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.

751 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