That_annoying_guyParticipantJuly 25, 2016 at 7:48 pmPost count: 42
That great for NEW users on the machines. What about existing users?
Consider using Set-ActiveSetup
If all the REG changes go to HKCU you should be able to something like this:
Set-ActiveSetup -StubExePath “$envWinDir\regedit.exe” -Arguments “/S
"%SystemDrive%\Program Files (x86)\PS App Deploy\PSAppDeployHKCUSettings.reg“” -Description ‘PS App Deploy Config’ -Key ‘PS_App_Deploy_Config’ -ContinueOnError $true
That_annoying_guyParticipantAugust 9, 2016 at 6:47 pmPost count: 42
Sorry, I meant something like this:
Set-ActiveSetup -StubExePath “$envSystem32Directory\reg.exe” -Arguments “import "%SystemDrive%\Program Files (x86)\PS App Deploy\PSAppDeployHKCUSettings.reg“” -Description ‘PS App Deploy Config’ -Key ‘PS_App_Deploy_Config’ -ContinueOnError $true
I took original from the .EXAMPLE in the Set-ActiveSetup. I will have to ask the Developers to update it.
The catch is that your REG file can only have entries for HKEY_CURRENT_USER. If you have HKEY_LOCAL_MACHINE entries in your REG file, they must be separated and imported during the install of the program.
FrancoisParticipantAugust 10, 2016 at 2:22 amPost count: 105
Set-RegistryKey–> Set registry but not from a reg file.
Set-ActiveSetup–> To use a .reg file and then set on HKCU from active setup
Invoke-HKCURegistrySettingsForAllUsers –> To set HKCU from HKU hive and will set default user as already create user and future user. But does not support .reg file. This one would be insteresting by just reading . reg file and set the value.
That_annoying_guyParticipantAugust 10, 2016 at 2:53 pmPost count: 42
None support .reg files directly and there is no converter at this time.
Set-RegistryKey affects one registry value at a time. In your case, if you have HKEY_LOCAL_MACHINE entries in your REG file, you must use this at install time.
ActiveSetup is a built-in feature of Windows that triggers an EXE to make per-user changes when a user logs in. The EXE is triggered ONCE and delays the showing of the desktop until it is done or fails. If it fail you will get no error message. If the EXE hangs or takes a long time to finish, you will think your computer is hung. Set-ActiveSetup creates the required registry keys in “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components” to make ActiveSetup to work. When a user logs in, the OS reads those sub-keys and creates a matching key name in “HKEY_CURRENT_USER\SOFTWARE\Microsoft\Active Setup\Installed Components”.
In your case, that EXE is REG.exe and you give reg.exe parameters. Just make sure that a regular user has the permissions to make those changes. The EXE file (and reg file in your case) must be reachable when the user logs in. If the regular user cannot run/read the file, it will fail. So a more complete code sample would be:
<code>#Copy the REG file on the machine Copy-File -Path "$dirFiles\PSAppDeployHKCUSettings.reg" -Destination "$envProgramFilesX86\PS App Deploy\PSAppDeployHKCUSettings.reg" -ContinueOnError $false #prepare ActiveSetup Set-ActiveSetup -StubExePath "$envSystem32Directory\reg.exe" -Arguments "import <code>&quot;$envProgramFilesX86\PS App Deploy\PSAppDeployHKCUSettings.reg</code>"" -Description 'PS App Deploy Config' -Key 'PS_App_Deploy_Config' -ContinueOnError $true</code>
Invoke-HKCURegistrySettingsForAllUsers take a more aggressive way of doing per-user changes. It locates all NTUSER.DAT files (Each user’s HKCU) and forces the changes in at install time. For future users, it modifies the Default user profile. I don’t like this route because I see it as pollutes the Default user profile. You could, in theory, make a change that makes new user profiles unusable.
The PSAppDeploymentToolkitAdminGuide.docx does mention some of this but it assumes you know what ActiveSetup is and how it works.
FrancoisParticipantAugust 10, 2016 at 5:38 pmPost count: 105
The downside of reg.exe or regedit is the UAC. When we are running regedit or reg there is a command window appearing and it takes a time before running. It will but it takes time. So there is a possibility a user would just close the window.
Yes, I know Active setup. Personnally, I believe all whose scenarios are usefull.
1. When configuring a new computer Invoke-HKCURegistrySettingsForAllUsers will make ready a computer for everyone for HKCU.
2. Set-RegistryKey is good for new computers and for change during software installation
3. Set-ActiveSetup is usefull to configure diverses user components. But the UAC might be a problem while changing HKCU with reg.exe or regedit as it might takes time. Is it a way to make it run minimize or hidden?
- This reply was modified 1 year, 6 months ago by Francois.
That_annoying_guyParticipantAugust 10, 2016 at 8:07 pmPost count: 42
I can’t reproduce the UAC prompt with reg.exe import <path to .reg file>
I tried on 3 computers in 3 different environments.
In one of our environments REG/Regedit is disabled for normal users but no UAC prompt.
So we usually launch a WiseScript exe that does registry the changes.
I’m sorry. I can’t help you.
You must find a way that a regular user can change their HKCU and use that in ActiveSetup.
That_annoying_guyParticipantAugust 10, 2016 at 8:16 pmPost count: 42
You must be logged in to reply to this topic.