I have a console program that read a registry key under HKCU:
OpenSubKey("Software\\Autodesk\\AutoCAD")
The program works very fine, but when I tried to use it as a Custom Action in an install project, it returned a null value.
Here are some suggestions:
- Turning off the UAC (user account control) will solve the problem.
- If I can run this console by double clicking it, it will work fine even if UAC is on.
If it’s returning
nullrather than throwing an exception, then it’s not a permissions issue – it’s that the key doesn’t exist.OpenSubKey:(And, note the exceptions listed above there):
So, the likely issue is that your action is being invoked during the install sequence, when it’s being run by the Windows Installer service – this service runs under the local system account, not under the logged in user’s account.
Not knowing what you’re trying to achieve with this key, I’m not sure what workaround to suggest. It may be that you can achieve your aims using standard built in facilities within the MSI system – or that you may want to defer this action until the first time you’re program actually runs.
(What’s possible inside the MSI may vary depending on what you’re using to build it – if you’re currently using a VS Setup project, you’ll be quite limited)