I need to execute some additional configuration after installation so I have created a smoll PostInstall.exe console application which should do the work. I need to get winamp install path from the registry.
This PostInstall.exe works fine if I run it alone. But if I use it in custom action "After Register Product", I get an error "The system cannot find the file specified" returned from the function
DWORD kres = RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Winamp",0, KEY_QUERY_VALUE, &hKey);
I am 100% sure that the key exists - I verify it before I launch installation. Also when I run PostInstall.exe manually after installation, it succeeds.
I have tried to set "Deferred Execution" and "Deferred execution in system context" but that does not help.
Why does RegOpenKeyEx fail in my custom action?
Make sure that the installation is not being elevated under another user account. This way your custom action process will not be executed for a different user which has a different HKEY_CURRENT_USER hive.
Also, try getting the current user inside your custom code and determine if it's the one you expect.