Common entry point for installation and uninstallation.

Got a problem you cannot solve? Try here.
Post Reply
bokkie
Posts: 767
Joined: Sun Feb 08, 2009 6:30 am

Common entry point for installation and uninstallation.

Post by bokkie »

In the MSIcode window is there a common place that both the installation and uninstallation would use? I can't quite see it if there is one. What I'm looking for is a place where I could create and initialise variables which I'd like to be eligible for use both when installing and uninstalling, that sort of thing. Another trivial example is maybe writing to a log file when the application is installed and uninstalled.
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP
StyX
Posts: 51
Joined: Fri Apr 11, 2008 7:14 am
Location: Stavanger, Norway
Contact:

Post by StyX »

Short version:
Entry point for booth is line 1.

Long version:
Booth the installer and uninstaller start at the top of the code and work their way through. In my setup that I'm working on currently (which I think is at least close to the default one generated if you use the wizard) what decides if it's installing or uninstalling is if the MAINTENANCE varible is set to true and NEEDSUPGRADE equals false then you are only uninstalling.

If NEEDSUPGRADE is set to true it will first uninstall and then go back and run the install part.

What I've done for easy access to all of my variables is simply placing them inside their own Code folding region at the top of the script. So the first thing the installer does is go through and initialize the varibles that I will need to install and uninstall. I've messed around alittle here and tried placing them different places and I can't see any difference preformance wise if I only initialize the varibles I need in order to install and not just do all like I do now.
bokkie
Posts: 767
Joined: Sun Feb 08, 2009 6:30 am

Post by bokkie »

Styx,

If I understand you correctly, execution is therefore always linear starting from line 1 until such time as the code branches or makes other decisions?

That's fine with me as line 1 is always a nice place to start! :lol:
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP
StyX
Posts: 51
Joined: Fri Apr 11, 2008 7:14 am
Location: Stavanger, Norway
Contact:

Post by StyX »

Yes.....
bokkie
Posts: 767
Joined: Sun Feb 08, 2009 6:30 am

MSIcode regions.

Post by bokkie »

A little off topic perhaps but is it possible to wrap code in a Define Region. I can see other regions but I can't find anything in the MSIcode window that would let me insert a region of my own. I guess it's possible but I can't see how to.
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP
StyX
Posts: 51
Joined: Fri Apr 11, 2008 7:14 am
Location: Stavanger, Norway
Contact:

Post by StyX »

Select a line and type: Code folding region.
Then hit Enter.
bokkie
Posts: 767
Joined: Sun Feb 08, 2009 6:30 am

Post by bokkie »

StyX wrote:Select a line and type: Code folding region.
Then hit Enter.
If that was snake it would have bitten me.

I was looking for Define Region. Doh! (slapping forehead).
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP
StyX
Posts: 51
Joined: Fri Apr 11, 2008 7:14 am
Location: Stavanger, Norway
Contact:

Post by StyX »

hehe, I did the exact same thing :)

Darn Visual Studio shortcut is to blame :p
MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Post by MichaelNesmith »

By the way folks, initializing variables all the way on top is fine, but pre-generated InstallAware scripts generally do this in the Define Setup Globals code folding region, and they initialize variables which should only be initialized on first run inside the Setup User Interview code folding region, right below the comment First Time Install. You can do the same or do it your way, nothing is hard coded in InstallAware, so do as you please :)

One important note is if you do not want to re-initialize variables with default values on further runs of setup (i.e. you want the values assigned on first run, possibly by the end-user, to survive), check the Remember value when restarting setup option in the Set Variable command window.
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
bokkie
Posts: 767
Joined: Sun Feb 08, 2009 6:30 am

Post by bokkie »

MichaelNesmith wrote:One important note is if you do not want to re-initialize variables with default values on further runs of setup (i.e. you want the values assigned on first run, possibly by the end-user, to survive), check the Remember value when restarting setup option in the Set Variable command window.
Nice. I can see a use for that.
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP
Post Reply