Folder-rename not done for uninstall invoked by install

Got a problem you cannot solve? Try here.
Post Reply
JohnO
Posts: 127
Joined: Tue Jun 18, 2013 9:52 am

Folder-rename not done for uninstall invoked by install

Post by JohnO »

I have the following statement that renames a folder during uninstall (so that it is kept for the next version):

Code: Select all

[DEFINE REGION: Perform Uninstallation]
if Variable REMOVE Equals TRUE
  Comment: Uninstall product
  Comment: TO-DO: Insert any additional uninstall commands here
  Set Variable NATIVE_ENGINE to TRUE
  Move Local Files $MYPROFILES$\Romonet\$TITLE$ #RSS_BETA_VERSION#\resources\*.* to $MYPROFILES$\Romonet\$TITLE$ #RSS_BETA_VERSION#\resources_old\ (include subfolders)
  Set Variable NATIVE_ENGINE to FALSE
This works when I explicitly invoke uninstall. However, after generating a new installer, when I install it, and the current version is detected, the installer uninstalls the current version. However, the folder-rename does not happen.

Why? What do I have to do to make the folder-rename happen for all uninstalls.

Regards, John
FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Folder-rename not done for uninstall invoked by install

Post by FrancescoT »

Dear John,

you should add the same functionality within the "[DEFINE REGION: Install Application Pre-Requisites]" also.

When a setup package is un-installed running the setup package itself, if a previous version is found installed on target, the Un-Install process is handled by "[DEFINE REGION: Install Application Pre-Requisites]" in your setup script.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
JohnO
Posts: 127
Joined: Tue Jun 18, 2013 9:52 am

Re: Folder-rename not done for uninstall invoked by install

Post by JohnO »

Dear Francesco
I have copied the code that I think is required, to the 'Install pre-req' REGION, but it is not effective. Perhaps I need something else or extra?

My added code is after "[compiler if Variable BUILDMODE not Equals PATCH" and is bounded by comments:

Code: Select all

[DEFINE REGION: Install Application Pre-Requisites]
Comment: Install setup pre-requisites
if Variable PREREQ not Equals FALSE
  Display Dialog: prereq, wait for dialog to return (modal)
  if Variable WIZARD Equals CANCEL
    Terminate Installation
  end
  Display Dialog: progressprereq, use as progress dialog (non-modal)
  [compiler if Variable BUILDMODE not Equals PATCH]
  if Variable NEEDSUPGRADE Equals TRUE
    Comment: This rename is copied from the Uninstall, so that it happens when uninstall is invoked during install
    Set Variable NATIVE_ENGINE to TRUE
    Move Local Files $MYPROFILES$\Romonet\$TITLE$#RSS_BETA_VERSION#\resources\*.* to $MYPROFILES$\Romonet\$TITLE$ #RSS_BETA_VERSION#\resources_old\ (include subfolders)
    Set Variable NATIVE_ENGINE to FALSE
    Comment: End of code copied from uninstall
    Set Variable REMOVEOLD to 
    Set Variable ERROROLD to 
    Install/Remove MSI Package $PRODUCTCODE$[REMOVE=ALL] (get result into variable REMOVEOLD)
I have stepped through the installer in debug mode. I can see my move code being executed, but the folder is not re-named.

In debug mode, the un-install fails, because it says I don't have the admin rights to un-install! I don't know why, as I use an id with local admin rights. Is the answer to run IA itself, as an administrator?

Regards, John

Regards, John
FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Folder-rename not done for uninstall invoked by install

Post by FrancescoT »

Dear John,

are you sure that all the variables you are passing to the command are correctly resolved?
Where do you intialize them in your code sequence?

Of course you should run IA as Admin to debug the un-install.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
JohnO
Posts: 127
Joined: Tue Jun 18, 2013 9:52 am

Re: Folder-rename not done for uninstall invoked by install

Post by JohnO »

Dear Francesco
I don't explicitly initialise compiler variables in my code. They are defined in Project Settings - some have a value and others default to 'empty'. Their values are set or changed from the command line as 'user parameters', e.g "RSS_BETA_VERSION=2.2Beta" or "RSS_BETA_VERSION=", in my build script.

This code is a copy of the code that runs when explicitly un-installing, and the compiler variables must have the correct value, because that works.

I will try changing the failing code to have a hard-coded value for the compiler variable, and see what happens.

<EDIT>
I removed the RSS_BETA_VERSION compiler version from the code, as its current value is 'empty'.
Unfortunately, the folder did not get renamed when uninstalling at the start of a new install.

Here is a description of what is supposed to happen:
1. The installer creates and populates a folder called 'resources' in the user's home directory. We need to keep its contents after the product is uninstalled, as changes are needed by the next version.
2. During un-installation, the 'resources' folder is renamed to 'resources-old' ('move' is used for this, though it actually does a copy, as 'resources' is still there)
3. as 'resources' was created by the installer, it gets removed, anyway.

This is what happens when I explicitly uninstall the product. It should happen when the current version is uninstalled as part of installing a new version 'over' the current one. This is the most likely scenario, so it is most important that this happens at this time.

The code, in full context, looks like this (my lines are highlighted with a '<==)':

Code: Select all

  Display Dialog: progressprereq, use as progress dialog (non-modal)
  [compiler if Variable BUILDMODE not Equals PATCH]
  if Variable NEEDSUPGRADE Equals TRUE
    Comment: Copied from the un-inststall section below - used here when uninstalling current product, as part of installing new version <==
    Set Variable NATIVE_ENGINE to TRUE <==
    Move Local Files $MYPROFILES$\Romonet\$TITLE$\resources\*.* to $MYPROFILES$\Romonet\$TITLE$\resources_old\ (include subfolders) <==
    Set Variable NATIVE_ENGINE to FALSE <==
    Apply Uninstall (get result into variable SUCCESS) <==
    Comment: End of delete and rename code, copied from the uninstall section <==
    Set Variable REMOVEOLD to 
    Set Variable ERROROLD to 
    Install/Remove MSI Package $PRODUCTCODE$[REMOVE=ALL] (get result into variable REMOVEOLD)
    if Variable REMOVEOLD Equals ERROR
      MessageBox: $TITLE$ Setup, Unable to uninstall old version of $TITLE$. Please uninstall it yourself using Control Panel Add-Remove Programs before attempting to install this product.$NEWLINE$$NEWLINE$$ERROROLD$
      Terminate Installation
    end
    if Variable REMOVEOLD Equals REBOOT
      MessageBox: $TITLE$ Setup, Your computer needs to be restarted before $TITLE$ Setup can continue.$NEWLINE$$NEWLINE$Please save your work in all running programs and click OK to restart your computer. Setup will resume once your computer restarts.$NEWLINE$$NEWLINE$If you click CANCEL, setup will exit. You will have to run setup again at a later time to install $TITLE$.
      if Variable REBOOTNOW Equals OK
        Reboot Computer and Resume Setup
        else
        Terminate Installation
      end
    end
    Set Variable MAINTENANCE to FALSE
  end
  [compiler end]
  Hide Dialog

</EDIT>

Regards, John
JohnO
Posts: 127
Joined: Tue Jun 18, 2013 9:52 am

Re: Folder-rename not done for uninstall invoked by install

Post by JohnO »

Dear Francesco
I took the idea of showing a message box in my added code from the sample, and displayed: Title and User's Home Directory. The latter has not been set:

Code: Select all

    MessageBox: Debug, TITLE=$TITLE$$NEWLINE$MYPROFILES=$MYPROFILES$
In the message box, Title was resolved to the title, but the home directory was not, it displayed as '$MYPROFILES$'.

Why is this not working in uninstall-before-installing, but it does work when you invoke 'uninstall' as an action?

Regards. John
FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Folder-rename not done for uninstall invoked by install

Post by FrancescoT »

Dear John,

... very probably you set the value of your variable just after in your code.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
JohnO
Posts: 127
Joined: Tue Jun 18, 2013 9:52 am

Re: Folder-rename not done for uninstall invoked by install

Post by JohnO »

Dear Francesco
I think there is something I don't understand about MSI coding. I am assuming that as $MYPROFILES$ is a predefined IA compiler variable for the user's home directory, it would always have that value.

How do I get it to be initialised earlier than it is by default?

Regards, John
JohnO
Posts: 127
Joined: Tue Jun 18, 2013 9:52 am

Re: Folder-rename not done for uninstall invoked by install

Post by JohnO »

Dear Francesco
Monday morning. A clear head.And, I got it!
I was looking at the MSI code, and I found a region called 'Define Setup Globals'. In there is a statement:

Code: Select all

Get Folder Location System->Profiles Directory into MYPROFILES
This comes after the code that performs an un-install at the start of an install. I coped the above line into the pre-req region, before my MOVE code, and it works now.

Problem solved!
John
FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Folder-rename not done for uninstall invoked by install

Post by FrancescoT »

:D :D :D
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Post Reply