View Full Version : Exit Code from Custom Actions (Quite urgent)

07-30-2001, 12:00 AM
txs :)
"Stefan Krueger" <nwsgrp@installsite.org> wrote in message
> Use LaunchAppEx from
> http://www.installsite.org/isp_ext.htm#LaunchAppEx
> --
> Stefan Krueger - Independent Setup Consultant
> InstallSite - code samples, tips, tools, bug lists, and more
> http://www.installsite.org http://www.installsite.de (GERMAN)
> Support and consulting http://www.installsite.org/krueger
> Stefan Krueger and the InstallSite web site are not affiliated
> with InstallShield Software Corporation.
> "Camilo da Silva Borges" <camilob@dbserver.com.br> schrieb im
> Newsbeitrag news:3b61d236@news.installshield.com...
> > How i can get an exit code from an application launched by Install
> Shield?
> >
> > txs
> >
> >
> >

11-16-2001, 06:56 AM
Hi again!!

Can someone please explain to me how I can return an Exit code from a VB Custom Action - I want my setup to stop if there is MSDE installed, or the user does not have admin rights (for NT and 2K). I have the code to check this however I do not understand how I can return an exit code to the setup routine which will force it to stop.

Any help will be gratefully appreciated.

Thank you in advance!!!

11-20-2001, 09:18 AM
Check out the API function ExitProcess which you can declare in VB like this:

Declare Sub ExitProcess Lib "kernel32" (ByVal procExitCode As Long)

Then you can use it to return a value from your Visual Basic application. A return value of 0 is considered OK, all other values is interpreted as a failure (as far as I have understood).

Don't forget that if you run the code in Visual Studio, the entire VB IDE will shut down ;-) which might not always be what U want. So only try the code in the EXE (unless you like to restart VB :-)

Good luck!

11-20-2001, 09:50 AM
Cheers for that info - that is certainly a help. although when terminating the process Install Shield is displaying an internal error (number 2744). This is however better than what we have at the moment.

I am actually using the Terminate Process API, as when using the ExitProcess regardless of the value being passed the process was always being terminated - weird.

Thanks again.

11-20-2001, 09:54 AM
We also got that error at one time. When do you invoke the custom action? If possible, change when it is invoked and try again.. I think we solved it this way.

12-14-2001, 07:45 AM
Hi dude,
Does it work that way really?
Because i tried the same thing by using the same API, I.e Exit Process. But the problem is irrespective of the value passed (0/1)
It is showing the error 2744 and terminating the Setup..
I am calling the custom exe after the customer information dialog.

Can u help me out...

Thanx yar


12-14-2001, 07:49 AM
Regarding the 2744, I think this is an internal error in the InstallShield Express engine somewhere... But I know we got rid of it when changing the custom action to invoke after installation is complete. In our case it was okay since we need to do some post-installation adoptions but in your case it might not be possible to delay the action... :-( It would be interesting to know whether InstallShield confirms the 2744 to be an "official bug"?

12-14-2001, 10:13 AM
Error 2744 is documented in the Windows Installer help simply as "Exe called by Custom Action failed". See if the following bit of information helps you. It was a post made on this board which seemed to solve someones question about VBScript returning values. Also, if you want your install to simply stop because the requirements are not met, you coul manually make entries in the LaunchCondition Table of the built msi (using a tool like ORCA - search this messageboard on how to get ORCA). You can get help on the LaunchCondition table from the Msi Help (from Express Help Menu).

ActiveX (or COM) Dlls cannot be called directly via a custom action they would need script such as:

Dim myObj
Set myObj=CreateObject("MyDLL.MyClass")


Set myObj=Nothing

Using VBScript, the only concept of a return value is if a function is used, e.g.

function foo()
end function

I have tried this, and although the function is definately being called the return value (0 or non-zero) makes no odds, the installer trundles on anyway....

It seems ridiculous to me that only a C/C++ custom action can influence the script in any way.

Looking at the Windows Installer API, there appears to be no simple COM based solution to affecting the installer progress, unless someone knows different.....



You can use one of the predefined values of msi.h
function foo()
foo = 1627
end function

this will work.

If you want to display a nice message, you can use session.Message (I didn't test that)

you could use an appropriate value from this set
#define ERROR_INSTALL_USEREXIT 1602L // User cancel installation.
#define ERROR_INSTALL_FAILURE 1603L // Fatal error during installation.
#define ERROR_FUNCTION_FAILED 1627L // Function failed during execution.