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

OnBegin doesn't execute

Hi,
I"m using Installshield 12 demo version.
When I run my test project the OnBegin event doesn't execute.
Below is my source code in setup.rul
Any help will be much appreciated.
Thanks
GJ
////////////////////////////////////////////////////////////////////////////////
//
// This template script provides the code necessary to build an entry-point
// function to be called in an InstallScript custom action.
//
//
// File Name: Setup.rul
//
// Description: InstallShield script
//
////////////////////////////////////////////////////////////////////////////////

// Include Ifx.h for built-in InstallScript function prototypes, for Windows
// Installer API function prototypes and constants, and to declare code for
// the OnBegin and OnEnd events.
#include "ifx.h"
#include "iswi.h"


// The keyword export identifies MyFunction() as an entry-point function.
// The argument it accepts must be a handle to the Installer database.
export prototype MyFunction(HWND);

// To Do: Declare global variables, define constants, and prototype user-
// defined and DLL functions here.


// To Do: Create a custom action for this entry-point function:
// 1. Right-click on "Custom Actions" in the Sequences/Actions view.
// 2. Select "Custom Action Wizard" from the context menu.
// 3. Proceed through the wizard and give the custom action a unique name.
// 4. Select "Run InstallScript code" for the custom action type, and in
// the next panel select "MyFunction" (or the new name of the entry-
// point function) for the source.
// 5. Click Next, accepting the default selections until the wizard
// creates the custom action.
//
// Once you have made a custom action, you must execute it in your setup by
// inserting it into a sequence or making it the result of a dialog's
// control event.

///////////////////////////////////////////////////////////////////////////////
//
// Function: MyFunction
//
// Purpose: This function will be called by the script engine when
// Windows(TM) Installer executes your custom action (see the "To
// Do," above).
//
///////////////////////////////////////////////////////////////////////////////
function MyFunction(hMSI)
// To Do: Declare local variables.
begin

// To Do: Write script that will be executed when MyFunction is called.

end;

function OnBegin( )

STRING nResult;


begin


if (GetDisk("f",nResult) < 0) then
MessageBox("No f: drive detected, exiting installation",SEVERE);
ExitInstall();
endif;

end;
Labels (1)
0 Kudos
8 Replies
Tampaite
Level 3

gigolojoe wrote:
Hi,
I"m using Installshield 12 demo version.
When I run my test project the OnBegin event doesn't execute.
Below is my source code in setup.rul
Any help will be much appreciated.
Thanks
GJ


Can you try running it in DEBUG mode and step thru' the code?
0 Kudos
gigolojoe
Level 4

Hi Tampaite,
I tried running in debug mode but wasn't able to step through the code.
Does it matter that I am using an msi project instead of an installscript project?
I tried using an install script project and installscript\msi project and neither would run my code.
Does the demo version have that feature disabled?
Thanks
0 Kudos
Tampaite
Level 3

gigolojoe wrote:
Hi Tampaite,

Does it matter that I am using an msi project instead of an installscript project?

Does the demo version have that feature disabled?
Thanks


It shouldn't matter which project you create. Evaluation version doesn't have DEBUG disabled(I just downloaded a copy and verified it).

Can you just add the below simple messagebox and see if you can step into it?

MessageBox("Hello World", INFORMATION);
0 Kudos
gigolojoe
Level 4

Hi,
Yup, I added that messagebox but it didn't pop up.
Do I have to create a custom action to hook into the setup.rul?
0 Kudos
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

InstallScript events (such as OnBegin) are supported only by InstallScript and InstallScript MSI projects. To run InstallScript code in a Basic MSI project, an InstallScript custom action needs to be created and sequenced where/when you would like the code to run. In addition, the custom action function needs to be defined and exported in the setup.rul (see the MyFunction prototype and implementation in the original post).

If you would like to use an event driven script, an InstallScript project is the recommended project type.
gigolojoe
Level 4

Groovy, thanks for the information.
0 Kudos
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

One other thing to note, and this may not matter if the code the post has in OnBegin is just some test code, but the GetDisk function is used to return the drive portion of a path passed to it. For example, GetDisk will return 'C:' if the path 'C:\Program Files\Test' was passed (the function return value is successful if a drive could be parsed out of the path, failure otherwise). To determine if a drive is present on a machine, use the ExistsDisk function instead which returns EXISTS (0) if the drive is present and NOTEXISTS (-1) if it isn't.
0 Kudos
gigolojoe
Level 4

cool, thanks for the information.
0 Kudos