BPeters
Posts: 17
Joined: Tue Aug 30, 2005 4:58 pm

Custom Action after Registry remove

Where do I add my custom action so it will run on an uninstall after the registry keys for that install have been removed.

Thanks
Brad
ciprian
Posts: 259
Joined: Thu Jul 14, 2005 12:56 pm
Location: Craiova, Romania
Contact: Website

Hi,

You could schedule your custom action under "Uninstall" action, as this standard action is executed after the "RemoveRegistryValues" action.

If you need further help please let me know.

All the best,
Ciprian
Ciprian Burca
Advanced Installer Team
http://www.advancedinstaller.com
BPeters
Posts: 17
Joined: Tue Aug 30, 2005 4:58 pm

When I set the custom action under Uninstall I have to set it to execute on commit. Before commit the registry values are still there. The problem now is that when I execute on commit the DLL containing the custom action is removed. This DLL is reference counted and used by other installs so this works when I uninstall all other apps except on the last one it causes error.

My installs have a reference count registry entry so my plan is to not run this custom action if the reference count is 0. My question is, is the Search on the registry performed on an Uninstall as well as an Install or do I need some script custom action to test and set a parameter for the reference count.

Thanks
Brad
BPeters
Posts: 17
Joined: Tue Aug 30, 2005 4:58 pm

After working on this problem for some time I have found that the search is preformed only on Install so that won't work. So I searched the help and found a post that suggests using MsiGetProperty to obtain property information from a DLL. I got that to work but am now trying to use MsiSetProperty to set a property in my install. This property will be used as a flag to run or not run the commit custom action. The problem is that MsiSetProperty doesn't seem to be working. Below is my code for my SetRecourseCount function.

int SetRepositoryReferenceCount(MSIHANDLE hInstall)
{

HKEY hEnvKey;
CString tKeyStr;
tKeyStr.Format("SOFTWARE\\Your Company\\Your App\\");

if (::RegOpenKeyEx(HKEY_LOCAL_MACHINE,tKeyStr,NULL,KEY_ALL_ACCESS,&hEnvKey) != ERROR_SUCCESS)
return (0);

DWORD pType;
BYTE * pBuffer;
DWORD pBytesUsed;

pBuffer = new BYTE[1024];
pBytesUsed = 1024;

if (::RegQueryValueEx(hEnvKey,"REF_COUNT",NULL,&pType,pBuffer,&pBytesUsed) != ERROR_SUCCESS)
{
delete [] pBuffer;
return (-1);
}

int tRefCount = (int)*pBuffer;
delete [] pBuffer;

::RegCloseKey(hEnvKey);

if(hInstall)
{
CString tRefCntStr;
tRefCntStr.Format("%d",tRefCount);

if(::MsiSetProperty(hInstall,"REF_COUNT",tRefCntStr) != ERROR_SUCCESS)
return (-1);
}

return (0);

}

Any help would be appriciated.

Thanks
Brad
ciprian
Posts: 259
Joined: Thu Jul 14, 2005 12:56 pm
Location: Craiova, Romania
Contact: Website

Hi Brad,

When creating a DLL that is executed by a custom action, if the entry function for that DLL is not specified by a .DEF file or by a /EXPORT linker specification, the signature of the function should be like this.

Code: Select all

UINT __stdcall ImmediateCustomAction(MSIHANDLE hInstall)
Also this type of custom action requires a handle to the install session so it must be set to be executed as immediate.

For more information on DLL custom actions please visit:

http://msdn.microsoft.com/library/defau ... ype_17.asp

http://msdn.microsoft.com/library/defau ... type_1.asp



All the best,
Ciprian
Ciprian Burca
Advanced Installer Team
http://www.advancedinstaller.com
BPeters
Posts: 17
Joined: Tue Aug 30, 2005 4:58 pm

Well I found a solution and thought I would post incase someone else had the same problem. All I had to do is when I set the custom action I want to occur after the Registry Keys are removed to be under Uninstall and execute on Commit set the Executions Properties to be Synchronous execution, ignore return code. That way if DLL isn't there it does not cause an error simple skips call. The operation is not that signigicant for other uninstalls so not checking the return is not an issue.

Thanks for you help
Brad
pritisinghip
Posts: 1
Joined: Thu Mar 29, 2018 1:43 pm
Contact: Website

Re: Custom Action after Registry remove

I added a registry key value into the registry on install.And I want to modify that registry key value on uninstall but I don't want to removing that from registry.
Daniel
Posts: 8279
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom Action after Registry remove

Hello and welcome to our forums,

We do not have predefined support for this, but you can develop your own custom action (to run on uninstall) which will re-create the reg value after it is deleted by the uninstall process.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
alexang2303
Posts: 1
Joined: Mon Dec 16, 2019 11:59 am
Contact: Website

Re: Custom Action after Registry remove

I think (but could easily be wrong!) that's only for deleting an entire Key, not an individual Value. You put the (-) in the Name column of Registry table, so I don't think I can use that to specify a value to delete. Unless I'm missing something?
Catalin
Posts: 7606
Joined: Wed Jun 13, 2018 7:49 am

Re: Custom Action after Registry remove

Hello and welcome to our forums,

I'm afraid I do not fully understand your scenario. Could you please give me some more details about what you want to achieve?

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”