Page 1 of 1

Run a program and exit IA if a file exists

Posted: Wed May 06, 2009 8:31 pm
by glenharvy
Hi,

Can I ask for suggestions please on the following:

I need to check if the user has an active support contract to perform an update. This information is contained within a licence file on their computer.

I have written a small program that checks this file and creates a semaphore file if the support period has expired.

What I want to do is have IA 1. install the checkingProgram file, 2. run that program and 3. delete the checking program and exit the main installation if the semaphore exists.

The checking program has it's own dialog boxes however I wouldn't mind having those displayed within IA.

I'm trying to cheat by using the bde upgrade pre-requisite as an example or template to install the checking program but this seems a bit over the top with all the dialogs etc. Is there a 'silent' install option for an IA project?

Posted: Thu May 07, 2009 1:41 am
by bokkie
1. You can add your executable as a support file. It will be used when you run the package and removed when it has finished. A file bag is better however.

2. Silent install? If we're talking about the actual package that is built, yes. If we're talking about pre-requisites, that sort of thing, maybe.

Posted: Thu May 07, 2009 1:57 am
by Bar_BQ
...and if you already made sure your semaphore file exists, then make exit like this:


IF MY_VAR EQUALS TRUE
THEN
goto label EXIT
END


label EXIT
Terminate Installation

Posted: Thu May 07, 2009 3:37 am
by glenharvy
bokkie wrote:1. You can add your executable as a support file. It will be used when you run the package and removed when it has finished. A file bag is better however.
Thank you for your comment which is much appreciated however I want my program to run before IA does anything else (including uninstall the current version - which it does at present).

To be more precise: the user downloads the IA setup program, runs it and the very first thing IA does is run my small program which tells the user their licence has expired and IA then closes gracefully. I thought this could be achieved by a pre-requisite but I'm now wondering if IA will uninstall a perfectly legit installation before checking if they can upgrade or not.

I'm beginning to think it may be easier to wrap the IA installer program in another self extracting archive (or even another IA project) and only run if the semaphore doesn't exist.

Surely however I can use the IA dialogs etc to make it all 10 times more professional :-)

Posted: Thu May 07, 2009 3:44 am
by Bar_BQ
There is no reason why you couldn't do it with IA. If you want to run your small application first, just include it into support files as Michael wrote, and use Run Program As function at the top of the script before any other commands are performed.

Posted: Thu May 07, 2009 7:18 am
by glenharvy
Bar_BQ wrote:There is no reason why you couldn't do it with IA. If you want to run your small application first, just include it into support files as Michael wrote, and use Run Program As function at the top of the script before any other commands are performed.
I wish I was a lot more experienced with all this but I just can't find any examples or other help in learning all this. How on earth did you ever learn all this stuff!

Anyhow, I've just discovered in MSICode where to add the file and I think I know how to add what I want to the script but exactly where in the script should I insert the (presumably) run my program? Is it 'Check Application Requirements' perhaps?

Posted: Thu May 07, 2009 7:58 am
by bokkie
It can go anywhere but you need to make sure it goes into the right place that suits your context. If you want to test it, create a new blank setup project. In the MSIcode tab put a breakpoint on the very first line in the code. Then start debugging. The first statement is the one executed. From thereon, you can step through the code line-by-line. It's completely linear until a condition is encountered. For example, do you want to display any standard dialogs like the welcome screen for example? If you do, put your code after the welcome screen. That way, your users know they are participating in an installation and not responding to a message box that looks like it came out of nowhere.

Another strategy is to put your specific code into a script file. That is, select the MSIcode tab and you'll see the Include Scripts node in the explorer. Select it, right-click and then select the Create New Script item. Enter a folder where you want the script to be created. Click Save. A new tab will appear in the MSIcode window. Select it and enter your code into that. That way, you or someone else can distinguish your code from standard code. You can then use the same script file in other projects making it easier to make changes. It's all personal choice. Finally, to use the script, select the main MSIcode code tab and use the Include Script command. You can then select the script file from the list available. This lets you refer to a potentially large script file using a single statement which makes it (a) easier to debug as you know what's your code and what's standard, and (b) it's much easier to move a single Include Script statement from one place to another as you won't leave orphaned code loitering which could damage your installation or make it deuced difficult to work out why something is broken.

Coming back to your original question, "where?", the choice is yours once you've identified the correct context where you want it to be executed. If you think learning IA is difficult - which it is not - then maybe you need to buy Wise or InstallShield. Excuse me while I gag for a moment. A day spent with those will convince you that IA is actually a brilliant concept. :D

Posted: Thu May 07, 2009 8:20 am
by glenharvy
bokkie - I can't thank you enough. Seriously, you have given me the info I need to start exploring and using IA.

There is just one more item that I need a little more help with .. when I run my support file (see - I'm even getting used to the terms :D ) I need to create the semaphore file in for example the users temp directory. There doesn't seem to be a ready-made path variable [or is it Target Directory] for a directory that is read/write enabled (the users temp directory in my case) that I can use in my IA variables. How do I reference that directory in the 'If File Exists' dialog?

Posted: Thu May 07, 2009 9:39 am
by bokkie
glenharvy wrote:bokkie - I can't thank you enough. Seriously, you have given me the info I need to start exploring and using IA.

There is just one more item that I need a little more help with .. when I run my support file (see - I'm even getting used to the terms :D ) I need to create the semaphore file in for example the users temp directory. There doesn't seem to be a ready-made path variable [or is it Target Directory] for a directory that is read/write enabled (the users temp directory in my case) that I can use in my IA variables. How do I reference that directory in the 'If File Exists' dialog?
That's a broad question which has many answers. You could use the Find All Files statement and enter the pathname where your utility will create the file. You can specify the filename you want to seach for and you'll get some text back into the variable you define to receive it. If you display the variable result in a MessageBox, you'll see what you need to check for in an if statement. There are probably more neater solutions or more concise ones but this should get you started. You can use a hard-coded pathname as all machines will have a C: drive (leastways, I've never come across one that didn't). You might want to research the pre-defined variables in the IA help system. In there is a variable called TEMPDIR which will give you something to work with.