Registry entry issue - Advanced Installer Community
vigyanlabsmys
Posts: 73
Joined: Sat May 17, 2014 12:37 pm

Registry entry issue

Hi,

I have added registry entry in AD installer. And I added custom action, in that I will launch an exe file which will read path from Registry.

I have added that custom action in "Install execution stage --> Finish execution --> launchFile".

The problem is in some machines before registry key entry appears in windows the custom action is executed and that exe file is unable to read path from Registry.
This behavior is only happening in silent install. And in non silent its working fine.

Please tell us how to solve this problem.??
Best Regards,
Dan
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Registry entry issue

Hi,

This may happens if Windows Installer uses a function like RegCloseKey to close a key after it was changed, in this case registry changes are flushed to disk when the registry uses its lazy flusher. Lazy flushing occurs automatically and regularly after a system-specified time interval.

"The RegCloseKey function does not necessarily write information to the registry before returning; it can take as much as several seconds for the cache to be flushed to the hard disk. If an application must explicitly write registry information to the hard disk, it can use the RegFlushKey function. RegFlushKey , however, uses many system resources and should be called only when necessary. RegFlushKey should only be called explicitly when an application must guarantee that registry changes are persisted to disk immediately after modification."

In your scenario WriteRegistryValues standard action, writes registry values into registry and from there it's lazy flusher work to flush this on hard disk, while your installation arrives to your custom action. A solution for this problem is to flush explicitly the registry key before trying to open it.

You can do this by using

Code: Select all

RegFlushKey(  hKey  );
in your custom action where hKey is a opened key or any of the following predefined key:

Code: Select all

HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_USERS
If there is anything else I can help you with, please let me know.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”