cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Diablo_m
Level 4

Abort installation in custom action

Hi everyone.

I have a big problem (for me) and I can't sort it out.... 😞

I have a basic MSI Installshield 2008 project. In a custom action I show the MessageBox with a question. It is shown on uninstallation after the ISSetAllUsers action. Then I check the result (what button the user presses) in the another custom action (I tried VBScript in the binary table). In this script I returns 3 if the user presses Cancel to cancel the uninstallation. The problem is that if the user presses Cancel button, the message "Fatal error during installation" occurs...:confused: How to prevent showing this message and cancel uninstallation in a right way?

Please help me, I can't find any real helpful information about this problem in the web!

Sincerely,
Mykhaylo Merkulov
Labels (1)
0 Kudos
(16) Replies
RobertDickau
Flexera Alumni

This old newsletter tip has a bit more information about exiting from a custom action: http://www.installshield.com/news/newsletter/0308-articles/msi.asp.
0 Kudos
Diablo_m
Level 4

RobertDickau wrote:
This old newsletter tip has a bit more information about exiting from a custom action: http://www.installshield.com/news/newsletter/0308-articles/msi.asp.


I've read this topic, but it didn't helped me. I did right what is written there.
1. I created a custom action (VB script in the binary table):
Function ExitSetup( )
ExitSetup = 3
End Function
2. This action is scheduled after showing the message box.

But when I press Cancel button is the message box, the following error is shown: "Fatal error during installation"....

May be this is another way to cancel the uninstallation?
0 Kudos
RobertDickau
Flexera Alumni

What does the message box code look like? As a test, does ExitSetup work without the message box?
0 Kudos
Diablo_m
Level 4

Message box code is just a custom DLL action, that calls a MessageBoxA function in the user32.dll and writes the result to the property. Then
if the result is 1 the custom VBScript action runs. ExitSetup works without message box, but the result error message still exists. 😞
0 Kudos
Diablo_m
Level 4

Also I tried to make a custom action which will call a DLL installed with the product. I scheduled this action after Initialize. But it also fails with the error that this dll could not be found (I've attached the screenshort) . Now I really don't know what to do. 😞
0 Kudos
RobertDickau
Flexera Alumni

If you're going to be using VBScript anyway, could you place the MsgBox call there?

If your DLL action is calling a file installed with the product, please take care that your action is scheduled for deferred mode somewhere after InstallFiles; otherwise, you might use a DLL in the Support Files view.
0 Kudos
Diablo_m
Level 4

RobertDickau wrote:
If you're going to be using VBScript anyway, could you place the MsgBox call there?


Yes, I can. But how can it fix the problem?

RobertDickau wrote:

If your DLL action is calling a file installed with the product, please take care that your action is scheduled for deferred mode somewhere after InstallFiles; otherwise, you might use a DLL in the Support Files view.
May be I wrote something wrong and you'd not understand me completely. This message should be shown during uninstallation, not installation.
If I schedule the custom action after InstallFiles it will not be executed because all files will be already deleted ( Am i right?)....
If I add this dll to the support files, I think it won't be available during uninstallion? If I'm wrong and support files are available during uninstallation, how can i create a custom action to call it?

Thank you for help! I'm new to the InstallShield and can't understand why it's so complex.
0 Kudos
RobertDickau
Flexera Alumni

Oh, right, during uninstallation you'll want to call the action before RemoveFiles. And you might try placing the DLL in the Binary table, which will be able available at uninstallation time.
0 Kudos
Diablo_m
Level 4

Thanks, I'will try it tomorrow.
0 Kudos
Diablo_m
Level 4

Hi, I just tried to place the DLL in the Binary Table and it's didn't helped me. I got the error that this DLL can't be found. Can you tell me what I'm doing wrong?

I've attached the test InstallShield project where I've created the custom action with DLL in the Binary Table.
0 Kudos
Not applicable

You should use an MSI DLL Custom Action instead of the Standard DLL Custom Action since that's the type of your DLL. It will be easier to understand.

Standard DLLs are designed to assist in migrating InstallScript or pure C style DLLs to the MSI style of doing things.

You already have an MSI DLL, so there's literally no reason of any kind that you would want to use the Standard DLL.
0 Kudos
Diablo_m
Level 4

bryanwolf wrote:
You should use an MSI DLL Custom Action instead of the Standard DLL Custom Action since that's the type of your DLL. It will be easier to understand.

Standard DLLs are designed to assist in migrating InstallScript or pure C style DLLs to the MSI style of doing things.

You already have an MSI DLL, so there's literally no reason of any kind that you would want to use the Standard DLL.


Thanks, I've changed the custom action to MSI DLL (NewCustomAction1 in the log). But now the uninstallation fails with the fatal error.

The log:
MSI (s) (44:48) [14:32:37:912]: Doing action: NewCustomAction1
Action ended 14:32:37: FindRelatedProducts. Return value 0.
MSI (s) (44:D0) [14:32:37:912]: Invoking remote custom action. DLL: C:\WINDOWS\Installer\MSI16.tmp, Entrypoint: ExitSetup
MSI (s) (44:4C) [14:32:37:912]: Generating random cookie.
MSI (s) (44:4C) [14:32:37:944]: Created Custom Action Server with PID 1104 (0x450).
MSI (s) (44:88) [14:32:38:037]: Running as a service.
MSI (s) (44:90) [14:32:38:037]: Hello, I'm your 32bit Impersonated custom action server.
Action start 14:32:37: NewCustomAction1.
Action ended 14:32:38: NewCustomAction1. Return value 3.
Action ended 14:32:38: INSTALL. Return value 3.
Property(S): DiskPrompt = [1]
Property(S): UpgradeCode = {1FD054A1-D191-4847-8289-F4383CD1EA22}
Property(S): Installed = 2008/02/06 16:28:44
Property(S): ACTION = INSTALL
Property(S): Preselected = 1
Property(S): UILevel = 3
Property(S): OriginalDatabase = c:\WINDOWS\Installer\48aca.msi
Property(S): DATABASE = C:\WINDOWS\Installer\48aca.msi
Property(S): Privileged = 1
Property(S): RedirectedDllSupport = 2
Property(S): MsiWin32AssemblySupport = 5.1.2600.3019
Property(S): MsiNetAssemblySupport = 2.0.50727.42
Property(S): Date = 2/6/2008
Property(S): Time = 14:32:38
Property(S): TTCSupport = 1
Property(S): VersionNT = 501
Property(S): ColorBits = 32
Property(S): TextHeight = 16
Property(S): BorderSide = 1
Property(S): BorderTop = 1
Property(S): CaptionHeight = 26
Property(S): CommonFilesFolder = C:\Program Files\Common Files\
Property(S): ScreenY = 768
Property(S): ScreenX = 1024
Property(S): SystemLanguageID = 1033
Property(S): ComputerName = GIZMOVMXP
Property(S): UserLanguageID = 1033
Property(S): UserSID = S-1-5-21-854245398-1897051121-725345543-500
Property(S): ProgramFilesFolder = C:\Program Files\
Property(S): LogonUser = Administrator
Property(S): AdminUser = 1
Property(S): VirtualMemory = 439
Property(S): PhysicalMemory = 256
Property(S): Intel = 15
Property(S): ShellAdvtSupport = 1
Property(S): OLEAdvtSupport = 1
Property(S): GPTSupport = 1
Property(S): FontsFolder = C:\WINDOWS\Fonts\
Property(S): DesktopFolder = C:\Documents and Settings\All Users\Desktop\
Property(S): StartMenuFolder = C:\Documents and Settings\All Users\Start Menu\
Property(S): ProgramMenuFolder = C:\Documents and Settings\All Users\Start Menu\Programs\
Property(S): StartupFolder = C:\Documents and Settings\All Users\Start Menu\Programs\Startup\
Property(S): AdminToolsFolder = C:\Documents and Settings\All Users\Start Menu\Programs\Administrative Tools\
Property(S): WindowsFolder = C:\WINDOWS\
Property(S): MyPicturesFolder = C:\Documents and Settings\Administrator\My Documents\My Pictures\
Property(S): LocalAppDataFolder = C:\Documents and Settings\Administrator\Local Settings\Application Data\
Property(S): CommonAppDataFolder = C:\Documents and Settings\All Users\Application Data\
Property(S): TemplateFolder = C:\Documents and Settings\All Users\Templates\
Property(S): SendToFolder = C:\Documents and Settings\Administrator\SendTo\
Property(S): RecentFolder = C:\Documents and Settings\Administrator\Recent\
Property(S): PrintHoodFolder = C:\Documents and Settings\Administrator\PrintHood\
Property(S): PersonalFolder = C:\Documents and Settings\Administrator\My Documents\
Property(S): NetHoodFolder = C:\Documents and Settings\Administrator\NetHood\
Property(S): FavoritesFolder = C:\Documents and Settings\Administrator\Favorites\
Property(S): AppDataFolder = C:\Documents and Settings\Administrator\Application Data\
Property(S): TempFolder = C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\
Property(S): RemoteAdminTS = 1
Property(S): System16Folder = C:\WINDOWS\system\
Property(S): SystemFolder = C:\WINDOWS\system32\
Property(S): ISCHECKFORPRODUCTUPDATES = 1
Property(S): ApplicationUsers = AllUsers
Property(S): AgreeToLicense = No
Property(S): _IsMaintenance = Change
Property(S): RestartManagerOption = CloseRestart
Property(S): SetupType = Typical
Property(S): _IsSetupTypeMin = Typical
Property(S): Display_IsBitmapDlg = 1
Property(S): ARPPRODUCTICON = ARPPRODUCTICON.exe
Property(S): DefaultUIFont = Tahoma8
Property(S): DialogCaption = InstallShield for Windows Installer
Property(S): DisplayNameCustom = Custom
Property(S): DisplayNameMinimal = Minimal
Property(S): DisplayNameTypical = Typical
Property(S): DWUSINTERVAL = 30
Property(S): ErrorDialog = SetupError
Property(S): InstallChoice = AR
Property(S): INSTALLLEVEL = 100
Property(S): IS_COMPLUS_PROGRESSTEXT_COST = Costing COM+ application: [1]
Property(S): IS_COMPLUS_PROGRESSTEXT_INSTALL = Installing COM+ application: [1]
Property(S): IS_COMPLUS_PROGRESSTEXT_UNINSTALL = Uninstalling COM+ application: [1]
Property(S): IS_PROGMSG_XML_COSTING = Costing XML files...
Property(S): IS_PROGMSG_XML_CREATE_FILE = Creating XML file %s...
Property(S): IS_PROGMSG_XML_FILES = Performing XML file changes...
Property(S): IS_PROGMSG_XML_REMOVE_FILE = Removing XML file %s...
Property(S): IS_PROGMSG_XML_ROLLBACK_FILES = Rolling back XML file changes...
Property(S): IS_PROGMSG_XML_UPDATE_FILE = Updating XML file %s...
Property(S): IS_SQLSERVER_AUTHENTICATION = 0
Property(S): IS_SQLSERVER_USERNAME = sa
Property(S): ISVROOT_PORT_NO = 0
Property(S): Manufacturer = Validio
Property(S): PIDTemplate = 12345<###-%%%%%%%>@@@@@
Property(S): ProductCode = {D83C9041-341E-4E68-BE7B-08CF1B317711}
Property(S): ProductID = none
Property(S): ProductLanguage = 1033
Property(S): ProductName = TestProject
Property(S): ProductVersion = 1.00.0000
Property(S): PROGMSG_IIS_CREATEAPPPOOL = Creating application pool %s
Property(S): PROGMSG_IIS_CREATEAPPPOOLS = Creating application Pools...
Property(S): PROGMSG_IIS_CREATEVROOT = Creating IIS virtual directory %s
Property(S): PROGMSG_IIS_CREATEVROOTS = Creating IIS virtual directories...
Property(S): PROGMSG_IIS_CREATEWEBSERVICEEXTENSION = Creating web service extension
Property(S): PROGMSG_IIS_CREATEWEBSERVICEEXTENSIONS = Creating web service extensions...
Property(S): PROGMSG_IIS_EXTRACT = Extracting information for IIS virtual directories...
Property(S): PROGMSG_IIS_EXTRACTDONE = Extracted information for IIS virtual directories...
Property(S): PROGMSG_IIS_EXTRACTDONEz = Extracted information for IIS virtual directories...
Property(S): PROGMSG_IIS_EXTRACTzDONE = Extracted information for IIS virtual directories...
Property(S): PROGMSG_IIS_REMOVEAPPPOOL = Removing application pool
Property(S): PROGMSG_IIS_REMOVEAPPPOOLS = Removing application pools...
Property(S): PROGMSG_IIS_REMOVESITE = Removing web site at port %d
Property(S): PROGMSG_IIS_REMOVEVROOT = Removing IIS virtual directory %s
Property(S): PROGMSG_IIS_REMOVEVROOTS = Removing IIS virtual directories...
Property(S): PROGMSG_IIS_REMOVEWEBSERVICEEXTENSION = Removing web service extension
Property(S): PROGMSG_IIS_REMOVEWEBSERVICEEXTENSIONS = Removing web service extensions...
Property(S): PROGMSG_IIS_ROLLBACKAPPPOOLS = Rolling back application pools...
Property(S): PROGMSG_IIS_ROLLBACKVROOTS = Rolling back virtual directory and web site changes...
Property(S): PROGMSG_IIS_ROLLBACKWEBSERVICEEXTENSIONS = Rolling back web service extensions...
Property(S): ProgressType0 = install
Property(S): ProgressType1 = Installing
Property(S): ProgressType2 = installed
Property(S): ProgressType3 = installs
Property(S): RebootYesNo = Yes
Property(S): ReinstallModeText = omus
Property(S): IS_PREVENT_DOWNGRADE_EXIT = A newer version of this application is already installed on this computer. If you wish to install this version, please uninstall the newer version first. Click OK to exit the wizard.
Property(S): SecureCustomProperties = ISFOUNDNEWERPRODUCTVERSION;USERNAME;COMPANYNAME;ISX_SERIALNUM;SUPPORTDIR;LAUNCHPROGRAM
Property(S): ALLUSERS = 1
Property(S): DWUSLINK = CECC80BFDEECA04F19AC378F89BB978F591B878FCE5C70AFCE7CC0D8CE6BC0E8BE4C27EFD9AC
Property(S): ARPURLINFOABOUT = http://www.Validio.com
Property(S): SHOWLAUNCHPROGRAM = 0
Property(S): NewProperty1 = 0
Property(S): NewProperty2 = 0
Property(S): WindowsVolume = c:\
Property(S): MsiNTProductType = 1
Property(S): ServicePackLevelMinor = 0
Property(S): ServicePackLevel = 2
Property(S): WindowsBuild = 2600
Property(S): VersionMsi = 3.01
Property(S): VersionDatabase = 200
Property(S): PRODUCTLANGUAGE = 1033
Property(S): CLIENTPROCESSID = 492
Property(S): CLIENTUILEVEL = 2
Property(S): COMPANYNAME = test
Property(S): CURRENTDIRECTORY = c:\WINDOWS\Installer
Property(S): USERNAME = XPSP2-vmw
Property(S): REMOVE = ALL
Property(S): ProductToBeRegistered = 1
Property(S): ProductState = 5
Property(S): PackageCode = {843BEDB9-0F30-4C88-8534-8D0DE5C67920}
MSI (s) (44:48) [14:32:38:303]: Note: 1: 1725
MSI (s) (44:48) [14:32:38:303]: Product: TestProject -- Removal failed.

MSI (s) (44:48) [14:32:38:303]: Cleaning up uninstalled install packages, if any exist
MSI (s) (44:48) [14:32:38:303]: MainEngineThread is returning 1603
MSI (s) (44:FC) [14:32:38:303]: Destroying RemoteAPI object.
MSI (s) (44:4C) [14:32:38:319]: Custom Action Manager thread ending.
=== Logging stopped: 2/6/2008 14:32:38 ===
MSI (c) (EC:A0) [14:32:38:319]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied. Counter after decrement: -1
MSI (c) (EC:A0) [14:32:38:319]: MainEngineThread is returning 1603
=== Verbose logging stopped: 2/6/2008 14:32:38 ===


Custom action:
// AbortInstallation.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"
#include "msi.h"
#include


#ifdef _MANAGED
#pragma managed(push, off)
#endif

BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}

UINT __stdcall ExitSetup(MSIHANDLE hInstall)
{
if (MessageBox(NULL,
(LPCWSTR)L"MESSAGE BOX TEXT",
(LPCWSTR)L"PRODUCT NAME",
MB_ICONWARNING | MB_OKCANCEL) == IDOK)
{
return 0;
}
else
{
return ERROR_INSTALL_USEREXIT;
}
}

#ifdef _MANAGED
#pragma managed(pop)
#endif
0 Kudos
Not applicable

Did you verify that you are calling the function properly? VC++ functions are decorated, so unless you export it properly, you'd have to ensure you're using the decorated function name.

Dependency Walker is useful for this type of investigation.
0 Kudos
RobertDickau
Flexera Alumni

To add to Bryan's suggestion, this old newsletter tip has a bit about setting up an MSI DLL: http://www.macrovision.com/webdocuments/PDF/dlls-for-ipwi.pdf?link_id=productsTipsTricks...
0 Kudos
Diablo_m
Level 4

Thank you, guys!
This topic helped me much. But I haven't prevaill. 😞

I've changed the DLL code as follows:

// AbortInstallation.cpp : Defines the entry point for the DLL application.
//
#pragma comment(lib, "msi.lib")

#include "stdafx.h"
#include "msi.h"
#include

__declspec(dllexport) UINT __stdcall ExitSetup(MSIHANDLE hInstall)
{
if (MessageBox(NULL,
(LPCWSTR)L"Test message",
(LPCWSTR)L"Product Name",
MB_ICONWARNING | MB_OKCANCEL) == IDOK)
{
return ERROR_SUCCESS;
}
else
{
return ERROR_INSTALL_USEREXIT;
}
}


And added the AbortInstallation.def:
LIBRARY "AbortInstallation"
EXPORTS
ExitSetup


Also i have specified the module-definition option in the project properties: /DEF:AbortInstallation.def

For testing purpose I have scheduled the custom action after SetupInitialization in the UI sequence.

The installation fails on the first screen.
The log:
[CODE]Action ended 15:46:21: SetupInitialization. Return value 1.
MSI (c) (24:F4) [15:46:21:203]: Doing action: NewCustomAction1
Action 15:46:21: NewCustomAction1.
Action start 15:46:21: NewCustomAction1.
MSI (c) (24:6C) [15:46:21:234]: Invoking remote custom action. DLL: C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\MSIFE.tmp, Entrypoint: ExitSetup
MSI (c) (24:10) [15:46:21:250]: Cloaking enabled.
MSI (c) (24:10) [15:46:21:250]: Attempting to enable all disabled priveleges before calling Install on Server
MSI (c) (24:10) [15:46:21:250]: Connected to service for CA interface.
Action ended 15:46:21: NewCustomAction1. Return value 3.
MSI (c) (24:F4) [15:46:21:562]: Doing action: SetupCompleteError
Action 15:46:21: SetupCompleteError.
Action start 15:46:21: SetupCompleteError.
Info 2826.Control ShowMsiLogText on dialog SetupCompleteError extends beyond the boundaries of the dialog to the right by 24 pixels.
Action 15:46:21: SetupCompleteError. Dialog created
MSI (c) (24:04) [15:46:21:671]: Note: 1: 2731 2: 0
Action ended 15:46:22: SetupCompleteError. Return value 2.
Action ended 15:46:22: INSTALL. Return value 3.
MSI (c) (24:F4) [15:46:22:312]: Destroying RemoteAPI object.
MSI (c) (24:10) [15:46:22:312]: Custom Action Manager thread ending. [/CODE]

Guys, can you tell me that's wrong?
0 Kudos
Not applicable

Have you run dependency walker against the built DLL? Also, having both __declspec(dllexport) and using a module definition file (DEF) is not going to work per the document on dllexport:

http://msdn2.microsoft.com/en-us/library/3y1sfaz2(VS.80).aspx

Specifically:

dllexport of a C++ function will expose the function with C++ name mangling. If C++ name mangling is not desired, either use a .def file (EXPORTS keyword) or declare the function as extern "C".


So you're probably still experiencing the name decoration.
0 Kudos