enigma
Posts: 89
Joined: Fri Jun 08, 2007 10:12 am

Uninstall an application automatically after installing it

I need to be able to uninstall an application automatically after it is installed.

Sounds weird isn't it. If an application is needed then why one needs to remove it right after installation?

But my case here is different. I have an application that is packaged into an installer. So when the installer is clicked, the application is installed and the application is run in order to perform an action. After that, the mission of the app is considered completed and should be removed.

So I need to be able to uninstall it immediately upon a successful installation.

Is there anyway to do this in Advanced Installer?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

You can do this by using custom actions.
In the "Custom Actions" page, under "InstallExecuteSequence->InstallFinalize" you create a Exe with working Dir custom action. You set "Asynchronous execution, do not wait for return" in the "Execution Properties" section and you set the "Full Path" to:

Code: Select all

msiexec /x [ProductCode] /qn
Note that /qn will make the uninstall silent.
In the "Install" tree you create a Launch File or Open URL custom action which will launch your application.

Regards,
cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
enigma
Posts: 89
Joined: Fri Jun 08, 2007 10:12 am

cosmin wrote:Hi,

You can do this by using custom actions.
In the "Custom Actions" page, under "InstallExecuteSequence->InstallFinalize" you create a Exe with working Dir custom action. You set "Asynchronous execution, do not wait for return" in the "Execution Properties" section and you set the "Full Path" to:

Code: Select all

msiexec /x [ProductCode] /qn
Note that /qn will make the uninstall silent.
In the "Install" tree you create a Launch File or Open URL custom action which will launch your application.

Regards,
cosmin
I am sorry, I do not understand what you mean.

You said that
In the "Custom Actions" page, under "InstallExecuteSequence->InstallFinalize"
But there is no "InstallFinalize" parameter anyway on the Custom Actions page. There is a "InstallExecuteSequence" folder. And under that folder there is a "uninstall", "Rollback", "Install" and "Commit" folder. But "InstallFinalize"? It's no way to be found.

And you said that
In the "Install" tree you create a Launch File or Open URL custom action which will launch your application.
I don't get this. I thought we have done what is needed in the "InstallExecuteSequence" and hence do not need to define a new action under "Install" folder tree?

The parameter to call the uninstallation program is, as you wrote:

Code: Select all

msiexec /x [ProductCode] /qn
I have a few questions here:
  1. How to specify the ProductCode? It's generated by Windows Installer and we usually don't know about it
  2. I read the help online, and found that one can replace ProductCode with the MSI path. I think it's easier to specify the MSI path rather than specifying the ProductCode for uninstallation purpose. This there anyway to get it?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,
But there is no "InstallFinalize" parameter anyway on the Custom Actions page.
You can add the "InstallFinalize" folder by right-clicking on the "InstallExecuteSequence" folder, you go to "Show Standard Action", then you go to "Before Finalization" and then on the bottom of the menu you click "InstallFinalize".
I don't get this. I thought we have done what is needed in the "InstallExecuteSequence" and hence do not need to define a new action under "Install" folder tree?
In order to execute your application after installing it, you need to make a custom action. That custom action will be in the "Install" folder, under the "InstallExecuteSequence" folder.
How to specify the ProductCode? It's generated by Windows Installer and we usually don't know about it

You don't specify it, you copy/paste msiexec /x [ProductCode] /qn in the "Full Path". [ProductCode] is a formatted property name which during installation will be expanded to the real product code.

Regards,
cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
enigma
Posts: 89
Joined: Fri Jun 08, 2007 10:12 am

cosmin wrote:Hi,
But there is no "InstallFinalize" parameter anyway on the Custom Actions page.
You can add the "InstallFinalize" folder by right-clicking on the "InstallExecuteSequence" folder, you go to "Show Standard Action", then you go to "Before Finalization" and then on the bottom of the menu you click "InstallFinalize".
I don't get this. I thought we have done what is needed in the "InstallExecuteSequence" and hence do not need to define a new action under "Install" folder tree?
In order to execute your application after installing it, you need to make a custom action. That custom action will be in the "Install" folder, under the "InstallExecuteSequence" folder.
How to specify the ProductCode? It's generated by Windows Installer and we usually don't know about it

You don't specify it, you copy/paste msiexec /x [ProductCode] /qn in the "Full Path". [ProductCode] is a formatted property name which during installation will be expanded to the real product code.

Regards,
cosmin
Great, this is exactly what I have been looking for. Thank you for your help
enigma
Posts: 89
Joined: Fri Jun 08, 2007 10:12 am

Now I realize that after the uninstallation, the empty application directory is still there, is there anyway to remove the empty application directory?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

You can do this using the "Folder Removal" dialog.
In the "Files and Folders" page you right-click "Application Folder" and select "Properties". In the "Remove" tab you check "Remove folder (only if empty)" and in the "Remove On:" combo you select "Component Uninstall".
http://www.advancedinstaller.com/user-g ... ialog.html

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Feature Requests”