Page 1 of 1

Prevent commands during install from reversing on uninstall

Posted: Wed Jul 20, 2011 7:28 am
by gsaunders
Using Installaware 11...

I need some clarification on what the uninstall actually does based on whether you are using purple commands, black commands, plug-in commands, and whether NATIVE_ENGINE is TRUE or FALSE.

Here is a sample (text view) of the region holding the Uninstall and Install regions and then I'll pose questions below:

Code: Select all

[DEFINE REGION: Process (Un)Installation]
label: Main Install
Comment: Exit Setup if Wizard Loop cancelled
if Variable WIZARD Equals CANCEL
  Terminate Installation
end
 
Comment: Prepare to install
Set Variable PROGRESSTEXT to Installing $TITLE$
Set Variable SUCCESS to 
Set Variable LASTERROR to 
if Variable ALLUSERS Equals TRUE
  Set Variable SHORTCUTFOLDER to $SHORTCUTFILESALL$\$STARTMENU$
  else
  Set Variable SHORTCUTFOLDER to $SHORTCUTFILES$\$STARTMENU$
end
Display Dialog: progress, use as progress dialog (non-modal)
 
Comment: Modify Target System
[DEFINE REGION: Perform Uninstallation]
if Variable REMOVE Equals TRUE
  Comment: Uninstall product
  Comment: TO-DO: Insert any additional uninstall commands here
  Apply Uninstall (get result into variable SUCCESS)
  Set Variable PROGRESS to 100
  else
  <<Code Folding Region>>
  [DEFINE REGION: Perform First Time or Maintenance Installation]
  Set Variable NATIVE_ENGINE to TRUE
  Create Folder $BAMPAAPPDATA$
  Set Read Write Permissions on File System Object "$BAMPAAPPDATA$" for Authenticated Users 
  Set Variable NATIVE_ENGINE to FALSE
   
  Comment: Custom Install/Re-Install product
  Comment: If OLDBAMPAEXISTS Copy old data to new folder
  if Variable OLDBAMPAEXISTS Equals TRUE
    Copy Local Files $OLDBAMPALOCATION$\*.dat to $BAMPAAPPDATA$    Copy Local Files $OLDBAMPALOCATION$\*.id to $BAMPAAPPDATA$    Copy Local Files $OLDBAMPALOCATION$\*.ind to $BAMPAAPPDATA$    Copy Local Files $OLDBAMPALOCATION$\*.inr to $BAMPAAPPDATA$    Copy Local Files $OLDBAMPALOCATION$\*.mmo to $BAMPAAPPDATA$    Copy Local Files $OLDBAMPALOCATION$\*.tdbd to $BAMPAAPPDATA$    Copy Local Files $OLDBAMPALOCATION$\*.xtr to $BAMPAAPPDATA$    Copy Local Files $OLDBAMPALOCATION$\*.xml to $BAMPAAPPDATA$    Copy Local Files $OLDBAMPALOCATION$\*.bmp to $BAMPAAPPDATA$    Copy Local Files $OLDBAMPALOCATION$\*.ini to $BAMPAAPPDATA$    Copy Local Files $OLDBAMPALOCATION$\*.* to $BAMPAAPPDATA$.OLD     
    Comment: If BAMPACOMPATIBILITYEXISTS Copy Virtual data to new folder
    if Variable BAMPACOMPATIBILITYEXISTS Equals TRUE
      Copy Local Files $BAMPACOMPATIBILITYLOCATION$\*.* to $BAMPAAPPDATA$      Copy Local Files $BAMPACOMPATIBILITYLOCATION$\*.* to $BAMPAAPPDATA$.OLD      Recursively Delete Files $BAMPACOMPATIBILITYLOCATION$      Call DLL Function kernel32.dll->RemoveDirectoryA
    end
     
    if Variable ISWINDOWS64BIT Equals TRUE
      Read Registry Key HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\BAMPA\UninstallString into OLDBAMPAUNINSTALL
      else
      Read Registry Key HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\BAMPA\UninstallString into OLDBAMPAUNINSTALL
    end
     
    if Variable OLDBAMPAUNINSTALL not Equals 
      MessageBox: Info, Begin Uninstall of old
      Run Program C:\PROGRA~1\\Bampa\UNWISE.EXE /S C:\PROGRA~1\\Bampa\INSTALL.LOG (WAIT)
      MessageBox: Info, Ran Uninstall
    end
     
    Recursively Delete Files $OLDBAMPALOCATION$    Call DLL Function kernel32.dll->RemoveDirectoryA
  end
   
  Comment: Install/Re-Install product
  Create Shortcut $SHORTCUTFOLDER$\Uninstall #TITLE# to $UNINSTALLLINK$
  [OFFLINE CONTENT]
  Install Files C:\D2010Apps\Bampa\InstallFiles_Current\*.* to $BAMPAAPPDATA$ (Permanent, Never Overwrite), ignore files matching wildcard pattern(s) *.scc
  Install Files C:\D2010Apps\Bampa\InstallFiles_Current\Hold_MMO\*.* to $BAMPAAPPDATA$ (Permanent), ignore files matching wildcard pattern(s) *.scc
  Install Files C:\Windows\System32\midas.dll to $WINSYSDIR$ (Permanent)
  Install Files C:\D2010Apps\Bampa\InstallFiles_Current\Hold_EXE\BAMPAx.exe to $TARGETDIR$
  Create Shortcut $SHORTCUTFOLDER$\BAMPA to $TARGETDIR$\BAMPAx.exe
  Create Shortcut $DESKTOPDIRALL$\BAMPA to $TARGETDIR$\BAMPAx.exe
  Create Shortcut $SHORTCUTFOLDER$\#TITLE# Update to $UNINSTALLLINK$
  [DEFINE WEB MEDIA Default]
  Get Component Default Selection State into Variable SELECTED
  if Variable SELECTED Equals TRUE
  end
  Comment: TO-DO: Insert any additional install commands here
  [compiler if Variable BUILDMODE Equals PATCH]
  Apply Patch (get result into variable SUCCESS)
  [compiler else]
  if Variable ADVERTISE Equals TRUE
    Apply Advertised (get result into variable SUCCESS)
    else
    Apply Install (get result into variable SUCCESS)
  end
  [compiler end]
  Set Variable PROGRESS to 100
end
<<Code Folding Region>>
<<Code Folding Region>>
Ok... you will see in the uninstall section (if Variable REMOVE Equals TRUE) we don't have anything custom at all. In the install section (if Variable REMOVE Equals True ... else) You see we have a mix of purple, black, and on plug-in command. Here are the questions:

1) Will the uninstall undo the actions of the purple commands?
2) Will the uninstall undo the actions of the black commands?
3) Will the uninstall undo the actions of the plug-in commands?
4) How does enabling NATIVE_ENGINE = TRUE effect the uninstall? Does it change what is actually undone?

Looking at our script sample you will see we basically do the following:
- Create a folder (PURPLE Command)
- set user rights (BLACK Command)
- Copy existing data from one local folder to the newly created one and a backup folder. (PURPLE Command)
- Recursively delete the data from the original local folder (BLACK Command)
- Use plug-in command to remove the original local folder (GREEN Command)
- Run an uninstall to an OLD Wise installer which removes an old program. (BLACK Command)
- Then we have the normal install files commands (PURPLE Commands)

I realize I will probably need to switch over to using NATIVE_ENGINE = TRUE for MOST if not ALL of the above commands so they go in the exact order, but let's say the order didn't matter for these next questions.

So some additional questions:

1) Will the uninstall undo all of the above commands OR just the purple ones?
2) What if they were all wrapped in the NATIVE_ENGINE = TRUE would they uninstall / undo?
3) And what if I do NOT want certain purple commands to undo / uninstall. How do I stop them from being undone during installation? What do I do with them?

As you can tell from the script I am basically moving around some local files and uninstalling an old application which I don't want to undo during an installation which is what has lead to my questions.

Thanks in advance for your help!

Greg

Re: Prevent commands during install from reversing on uninst

Posted: Wed Jul 20, 2011 10:35 pm
by giaviv
Hi Greg,

Those are some solid questions.

When the Native Engine is not used, the purple command do not execute until Apply Install is called.
Respectively, when Apply Uninstall is called, they are the only commands that get rolled back.
Black commands and green commands execute immediately and do not revert back on uninstall (unless you specifically specified in the command window - perform on uninstall).

When using the Native Engine, again only the purple commands roll back, however ALL commands execute immediately (unless the Native Engine is otherwise configured).

About preventing the rollback of purple commands, that's specific to every command - for example, the Install Files command has a checkbox that marks files as permanent, which means they don't get removed during uninstallation.