prasadus92
Posts: 58
Joined: Wed Feb 25, 2015 8:10 am

Custom action which writes to HKCU registry hive is failing

Hi,

I have a custom action which runs a VB Script to write a registry key under HKCU. The content of the VB Script file is given below:

Code: Select all

Dim WshShell, bKey, ver, regVal
Set WshShell = CreateObject("WScript.Shell")
bKey = WshShell.RegRead("HKCR\Outlook.Application\CurVer\")
ver = Right(bKey, 2)
regVal = "HKCU\Software\Policies\Microsoft\Office\" & ver & ".0\Common\Security\Trusted Protocols\All Applications\myprotocol:\"
WshShell.RegWrite regVal, ""
Set WshShell = Nothing
This custom action is failing every time. When I checked for the cause, after reading some posts, I came to know that writing under HKCU\Software\Policies is not allowed for a normal user and needs to be done by Admin only because the key contains policies enforced via GPO. But as this is HKCU, I am not sure if there is an alternate way to make it work. Can you guys please let me know if there is a workaround for this scenario?

Thanks in advance.

Regards,
Prasad
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Custom action which writes to HKCU registry hive is failing

Hi Prasad,

To run a custom action under the Local System account with full privileges you need to set its execution time to "When the system is being modified (deferred)" and its execution option to "Run under the LocalSystem account with full privileges(no impersonation)".

Also, you could use the predefined support from the Registry page.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”