all groups > visual studio .net setup > june 2007 >
You're in the

visual studio .net setup

group:

Deleting a custom action file after it has run


Deleting a custom action file after it has run David Jackson
6/22/2007 10:59:38 PM
visual studio .net setup: Hello,

Scenario: a WinForms app written in VS.NET 2005 (C#) and installed via a
Setup and Deployment project.

This is an upgrade of an old VB6 app which used the Registry to persist
certain data, but the C# app doesn't use the Registry - it uses the
Properties Settings.settings functionality instead.

Because I couldn't find any way in the standard Setup & Deployment project
to read values from the Registry and then copy them into the new
Settings.settings file, I wrote a small C# executable to do this instead,
which I set as a Custom Action in the Setup & Deployment project.

This is working correctly. The whole thing is packaged as an MSI. When it
runs, the upgrade executable is deployed along with the main app's files,
and is run at the end of the installation process. The resulting folder
looks something like this:

<MyApp>
MyApp.exe
MyApp.exe.config
MyApp.ico
MyApp_Upgrade.exe

What I would like to do now is have the MSI delete the MyApp_Upgrade.exe
file after it has run it, but there doesn't seem to be any way of doing this
in the Setup & Deployment project.

Curiously, if I delete it manually (or even have the main app delete it), it
gets recreated every time the app is run if the MSI is still on the machine!
I'm presuming there's some sort of setting for this which I have missed?

I should point out (in case anyone wonders) that the only reason I have for
wanting to do this is purely cosmetic / aesthetic... Leaving the
MyApp_Upgrade.exe in the application's installation folder causes no
problems whatsoever. But I would like to delete it because it's no longer
required.

Does anyone know of any way to do this?

Thanks,

DJ

Re: Deleting a custom action file after it has run Phil Wilson
6/23/2007 1:12:56 PM
Auto repair when you remove files is a default feature of MSI setups.
There's no setting in the IDE to rurn it off.

Does Visual Studio allow you to right-click Exclude on the executable in
solution explorer? If so, that runs it out of a temp location and is removed
afterwards.

--
Phil Wilson
[Microsoft MVP-Windows Installer]

[quoted text, click to view]

Re: Deleting a custom action file after it has run David Jackson
6/25/2007 12:00:00 AM
[quoted text, click to view]

Hi Phil,

Thanks for the reply.

[quoted text, click to view]

Ah - that would explain it!

[quoted text, click to view]

Yes it does.

[quoted text, click to view]

I tried that, but now the installer gives an error that it cannot find
Interop.IWshRuntimeLibrary...

The executable uses this library to search for unused icons on the target
machine's desktop and remove them if it finds any...

Thanks,

DJ

AddThis Social Bookmark Button