How to have PSADT write to HKCU under a System acct Install

There have been times where I’ve had an SCCM application deployment fail because the app install writes to the user’s registry hive. In other words, since the application is installed under the local system account, the HKCU specific keys are not written. To get around this easily is to have the application set to be run by the logged-in user. However, many environments are locked down and user’s don’t have the rights to install software.

One option is to add an Active Setup registry key via install script that will force an app to self heal once when the user logs on. But there’s an easier way using PSADT.

In the Post installation section and add:

[scriptblock]$HKCURegistrySettings = {

Set-RegistryKey -Key ‘HKEY_CURRENT_USER\SOFTWARE\Classes\Asdjgfeiyrbdi4wjf3s9’ -Name ‘NoOpenWith’ -Value ‘””‘-Type String -ContinueOnError:$True

}

Invoke-HKCURegistrySettingsForAllUsers -RegistrySettings $HKCURegistrySettings

Of course, you’d edit the reg key above to the one you want to write to HKCU.

Now you can have the application installed under the system context but still have the needed key(s) written to HKCU.

 

2 responses to “How to have PSADT write to HKCU under a System acct Install”

  1. ws2000 Avatar
    ws2000

    Hello

    I am trying to use the Invoke-HKCURegistrySettingsForAllUsers when installing an Adobe Reader update on Windows 10 x64. It is applying the updated registry keys in the current HKCU profile only. It is not applying them to either the existing or a new profiles. I am using PSADT 3.6.9. There are no errors reported in ISE

    [scriptblock]$HKCURegistrySettings = {
    Set-RegistryKey -Key ‘HKCU:SOFTWARE\Classes\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723’ -Name ‘NoOpenWith’ -Value ” -Type String -SID $UserProfile.SID
    Set-RegistryKey -Key ‘HKCU:SOFTWARE\Classes\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723’ -Name ‘NoStaticDefaultVerb’ -Value ” -Type String -SID $UserProfile.SID
    Set-RegistryKey -Key ‘HKCU:SOFTWARE\Classes\AppX4hxtad77fbk3jkkeerkrm0ze94wjf3s9’ -Name ‘NoOpenWith’ -Value ” -Type String -SID $UserProfile.SID
    Set-RegistryKey -Key ‘HKCU:SOFTWARE\Classes\AppX4hxtad77fbk3jkkeerkrm0ze94wjf3s9’ -Name ‘NoStaticDefaultVerb’ -Value ” -Type String -SID $UserProfile.SID
    }
    Invoke-HKCURegistrySettingsForAllUsers -RegistrySettings $HKCURegistrySettings`

    Any ideas?

    Thanks

  2. Scripters Avatar
    Scripters

    [scriptblock]$HKCURegistrySettings = {
    Set-RegistryKey -Key ‘‘HKEY_CURRENT_USER\SOFTWARE\Classes\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723’ -Name ‘NoOpenWith’ -Value ‘””‘ -Type String -SID $UserProfile.SID
    Set-RegistryKey -Key ‘HKEY_CURRENT_USER\SOFTWARE\Classes\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723’ -Name ‘NoStaticDefaultVerb’ -Value ‘””‘ -Type String -SID $UserProfile.SID
    Set-RegistryKey -Key ‘HKEY_CURRENT_USER\SOFTWARE\Classes\Classes\AppX4hxtad77fbk3jkkeerkrm0ze94wjf3s9’ -Name ‘NoOpenWith’ -Value ‘””‘ -Type String -SID $UserProfile.SID
    Set-RegistryKey -Key ‘HKEY_CURRENT_USER\SOFTWARE\Classes\AppX4hxtad77fbk3jkkeerkrm0ze94wjf3s9’ -Name ‘NoStaticDefaultVerb’ -Value ‘””‘ -Type String -SID $UserProfile.SID
    }
    Invoke-HKCURegistrySettingsForAllUsers -RegistrySettings $HKCURegistrySettings`

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.