VS. NET Installer 2003 - uninstall custom actions

V

Viviana Vc

Hi all,

I have to create an installer using VS. NET Installer from VS .NET 2003
-> "Setup and Deployment Projects" type of project that besides other
requirements has to also:

1) on uninstall show the user a dialog with 2 radio buttons (ie A and B)
and depending on his choise one exe will be executed (ie for A the
a.exe) or another (ie for B the b.exe) and the uninstaller will be
aborted after launching the b.exe
2) if the first exe was run (ie a.exe) and it returns a specific value
the uninstaller might need to abort right-away otherwise it has to
continue
3) on uninstalling delete some directories that were created while the
product ran on that computer

I read the MSDNL for this and:
a) seems I can add a specific dialog (the 2 radio buttons dialog) only
in case of install, as the "User Interface" dialog has just "Install"
and "Administrative Install". Seems there is no way of adding a new
dialog in uninstall case.
b) couldn't find any way of actually aborting the uninstaller at one
point, let's say depending of the return value of an exe that was
previously run.
c) in MSDNL is written "Custom actions are a Windows Installer feature
that allows you to run code at the end of an installation" which means
there is no way of adding a custom action (like running an exe) at the
end of the UNinstallation.

Taking in account the above notes I am not sure if I can accomplish the
1, 2 and 3 requirements I described above. Is this correct?

Thanks in advance,
Viv
 
S

Stefan Krueger [MVP]

a) seems I can add a specific dialog (the 2 radio buttons dialog) only
in case of install, as the "User Interface" dialog has just "Install"
and "Administrative Install". Seems there is no way of adding a new
dialog in uninstall case.

This is a limitation in Visual Studio, it is possible in Windows Installer.
Note however that clicking the Remove button in Add/Remove Programs control
panel will run your setup in Basic UI mode, which will not display your
authored dialogs, but only use Windows Installer's built in dialogs.
b) couldn't find any way of actually aborting the uninstaller at one
point, let's say depending of the return value of an exe that was
previously run.

Your EXE could return a value other than 0 to abort the installation.
c) in MSDNL is written "Custom actions are a Windows Installer feature
that allows you to run code at the end of an installation" which means
there is no way of adding a custom action (like running an exe) at the
end of the UNinstallation.

"Installation" means running your setup, either for the first time, or for
maintenance operation, such as repair, modify, uninstall, update. The same
sequence is used for all therse modes. In which of these cases your custom
action should run is determined by the condition you put on them. In Visual
Studio however you cannot control this.


--
Stefan Krueger
Microsoft Windows Installer MVP

Please post your questions in the newsgroup or vist one of these web sites:

Windows Installer FAQ
http://www.msifaq.com - http://www.msifaq.de

InstallSite - Resources for Setup Developers
http://www.installsite.org
http://www.installsite.de (GERMAN)
 
V

Viviana Vc

Thank you for your answer, which proves me that for our requirements we
can't use the VS .NET Installer 2003. This is what I wanted to know.

Thx,
Viv
 
S

Ste

I do something similar to what you want using VS .Net 2003 and custom actions.

On uninstall i invoke my dll, draw a modal dialog box and gather information - this takes place before files are removed.
It seems to work in all modes of operation; add/remove programs and from explorer

Here is a code extract

I added the dll like this .. in VS .Net 2003

Custom Actions->
Add dll..
Right click properties --> set EntryPoint to Uninstall /* can be anything you want here.. just make sure it matches the proto *.
set CustomActionData to [TARGETDIR]

UINT __stdcall Uninstall(MSIHANDLE hInstall) // export the fn().. i use a .def file
{

MsiGetProperty(hInstall, TEXT("CustomActionData"), TargetDir, &cchValue);
MessageBox(NULL, TargetDir, "Uninstalling", MB_OK);

HINSTANCE hInst = GetCurrentModule()
hDialog = CreateDialog(hInst, MAKEINTRESOURCE(DLG_MAIN), 0,(DLGPROC)DialogProc)

}

// to get the current HINSTANCE needed for a dialog i do

#if _MSC_VER >= 1300
#ifndef _delayimp_h
extern "C" IMAGE_DOS_HEADER __ImageBase;
#endif
#endif

HMODULE GetCurrentModule()
{
#if _MSC_VER < 1300 // earlier than .NET compiler (VC 6.0)
// Here's a trick that will get you the handle of the module
// you're running in without any a-priori knowledge:
// http://www.dotnet247.com/247reference/msgs/13/65259.aspx
MEMORY_BASIC_INFORMATION mbi;
static int dummy;
VirtualQuery( &dummy, &mbi, sizeof(mbi) );
return reinterpret_cast<HMODULE>(mbi.AllocationBase);
#else // VC 7.0
// from ATL 7.0 sources
return reinterpret_cast<HMODULE>(&__ImageBase);
#endif
}
 
S

Stefan Krueger [MVP]

I guess that means that your setup can no longer be uninstalled in
unattended mode (at least not in Basic MSI mode). Displaying dialogs in the
execute sequence is not recommended.

--
Stefan Krueger
Microsoft Windows Installer MVP

Please post your questions in the newsgroup or vist one of these web sites:

Windows Installer FAQ
http://www.msifaq.com - http://www.msifaq.de

InstallSite - Resources for Setup Developers
http://www.installsite.org
http://www.installsite.de (GERMAN)


I do something similar to what you want using VS .Net 2003 and custom
actions.

On uninstall i invoke my dll, draw a modal dialog box and gather
information - this takes place before files are removed.
It seems to work in all modes of operation; add/remove programs and from
explorer

Here is a code extract

I added the dll like this .. in VS .Net 2003

Custom Actions->
Add dll..
Right click properties --> set EntryPoint to Uninstall /* can be anything
you want here.. just make sure it matches the proto *.
set CustomActionData to [TARGETDIR]

UINT __stdcall Uninstall(MSIHANDLE hInstall) // export the fn().. i use a
..def file
{

MsiGetProperty(hInstall, TEXT("CustomActionData"), TargetDir, &cchValue);
MessageBox(NULL, TargetDir, "Uninstalling", MB_OK);

HINSTANCE hInst = GetCurrentModule()
hDialog = CreateDialog(hInst, MAKEINTRESOURCE(DLG_MAIN),
0,(DLGPROC)DialogProc)
}

// to get the current HINSTANCE needed for a dialog i do

#if _MSC_VER >= 1300
#ifndef _delayimp_h
extern "C" IMAGE_DOS_HEADER __ImageBase;
#endif
#endif

HMODULE GetCurrentModule()
{
#if _MSC_VER < 1300 // earlier than .NET compiler (VC 6.0)
// Here's a trick that will get you the handle of the module
// you're running in without any a-priori knowledge:
// http://www.dotnet247.com/247reference/msgs/13/65259.aspx
MEMORY_BASIC_INFORMATION mbi;
static int dummy;
VirtualQuery( &dummy, &mbi, sizeof(mbi) );
return reinterpret_cast<HMODULE>(mbi.AllocationBase);
#else // VC 7.0
// from ATL 7.0 sources
return reinterpret_cast<HMODULE>(&__ImageBase);
#endif
}
 
S

Ste

Stefan,

When you mention "unattended mode", do you mean uninstall with no user
interaction [silently] or is there something more subtle i should be aware
of?

For my particular package & needs, the user must be interact with the
installer as there are some important decisions that need to be made; the
installer
will never be the installed in silent mode. I have searched msdn but cannot
find an alternative to popping a dialog box up, nor can i find a complete
description
as to why dialogs in the execute sequence is not recommended - can you point
me in the right direction?
 
V

Viviana Vc

Is there a way in the installer to call my own exe with some specific
params in case there is a silent uninstall? If yes, then it could be
done like:
- if the setup is run in interactive mode run my exe which will show
also my dialogs
- if the setup is run in silent mode run my exe with some params which
will consider some defaults values so it won't show my dialogs anymore
But for this we need in the installer to call the exe with diff params
depending if it's silent mode or interactive.

Also I am pretty sure out there are application that always need user
interaction when uninstalling. Not every uninstall can be silent I would
say.

Thx,
Viv
 
V

Viviana Vc

Pls see my answer below ....

This is a limitation in Visual Studio, it is possible in Windows Installer.
Note however that clicking the Remove button in Add/Remove Programs control
panel will run your setup in Basic UI mode, which will not display your
authored dialogs, but only use Windows Installer's built in dialogs.

Are you saying that regardless if I create let's say with InstallShield
custom dialogs for my installer (in case of uninstalling) those won't be
shown if the user choses Add/Remove programs and this is b/c the
uninstaller will run in Basic UI mode which doesn't show these dialogs?
How can this be? I mean why then to create those dialogs?

Thank you,
Viv
 
S

Stefan Krueger [MVP]

When you mention "unattended mode", do you mean uninstall with no user
interaction [silently] or is there something more subtle i should be aware
of?

Yes, that's what I mean. This would happen for instance if your setup is
deployed via ActiveDirectory or some other automatic deployment technology.
Supporting such deployment scenarios is one common reason why developers
chose MSI technology.

--
Stefan Krueger
Microsoft Windows Installer MVP

Please post your questions in the newsgroup or vist one of these web sites:

Windows Installer FAQ
http://www.msifaq.com - http://www.msifaq.de

InstallSite - Resources for Setup Developers
http://www.installsite.org
http://www.installsite.de (GERMAN)
 
S

Stefan Krueger [MVP]

Are you saying that regardless if I create let's say with InstallShield
custom dialogs for my installer (in case of uninstalling) those won't be
shown if the user choses Add/Remove programs and this is b/c the
uninstaller will run in Basic UI mode which doesn't show these dialogs?
Yes.

How can this be? I mean why then to create those dialogs?

When uninstalling by clicking the "Remove" button in Add/Remove Programs
Windows Installer will use its built in progress bar. It will not display
any dialogs you have authored. So it doesn't make sense to add any dialogs
for this case.

However if you click the Modify button your setup will run in full UI mode.
Typically you display a MaintenanceTyoe dialog asking the user whether he
wants to modify, repair, or uninstall the application. In this case oyu can
display dialogs, incuding the uninstall case.

You can disable the Remove button in Add/Remove Programs by setting the
ARPNOREMOVE property, thus forcing the user to go throught the Modify
option.

--
Stefan Krueger
Microsoft Windows Installer MVP

Please post your questions in the newsgroup or vist one of these web sites:

Windows Installer FAQ
http://www.msifaq.com - http://www.msifaq.de

InstallSite - Resources for Setup Developers
http://www.installsite.org
http://www.installsite.de (GERMAN)
 
V

Viviana Vc

Thank you. I understood.

But in this case what happens in the following scenario (let's say the
uninstaller sequence in full-ui is):
- show a 2 radio-buttons dialog to the user
- if the user chooses A then a.exe is run
- if the user chooses B then b.exe is run

What happens if now the "Remove" is chosen? The dialog won't be shown,
but what happens with the exes that normally are run depending on the
user selection? Is a default one run? Or none of them?

Thank you,
Viv
 
S

Stefan Krueger [MVP]

That depnds on how you call those executables in your setup.
If you launch them at the moment the user clicks Next on that
radio-button-dialog: none of them will run. Anything your setup is supposed
to do in the UI sequence will not happen. Therefore it's recommended that
any action that modifies the target machine should be in the Execute
sequence.
So if you call thoses EXEs in the Execute sequence, based on a condition
that uses the property that this radio-button dialog sets: it will use the
default value of that property and run the matching exe.

--
Stefan Krueger
Microsoft Windows Installer MVP

Please post your questions in the newsgroup or vist one of these web sites:

Windows Installer FAQ
http://www.msifaq.com - http://www.msifaq.de

InstallSite - Resources for Setup Developers
http://www.installsite.org
http://www.installsite.de (GERMAN)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top