Uninstall script logic

Got a problem you cannot solve? Try here.
glenharvy
Posts: 167
Joined: Fri Sep 14, 2007 3:53 am

Uninstall script logic

Postby glenharvy » Wed Jul 01, 2015 6:01 pm

Hi,
I need some help understanding the logic behind the uninstall operation in IA. Here's my code:

Code: Select all

[DEFINE REGION: Perform an UnInstallation]
if Variable REMOVE Equals TRUE
  Comment: Uninstall product
  Comment: TO-DO: Insert any additional uninstall commands here
  Set Variable PROGRESSTEXT to Un-Installing $TITLE$
   
  Set Variable TD to
  Set Variable TDD to $TARGETDIR$\nonexist.exe
  Replace \\ with \: TDD
  Extract File Folder: TDD
  Parse String $TDD$ into Variables TD and  (Split at last occurrence of pattern)
   
  Set Variable DD to
  if Variable MCDATADIR Equals
    Set Variable MCDATADIR to $MCSharedDataDirectory$
  end
  Set Variable DDD to $MCDATADIR$\nonexist.exe
  Replace \\ with \: DDD
  Extract File Folder: DDD
  Parse String $DDD$ into Variables DD and  (Split at last occurrence of pattern)
   
  Set Variable isAbyssWebServerInstalled to
  Check Service State for AbyssWebServer (write result into variable isAbyssWebServerInstalled)
  if Variable isAbyssWebServerInstalled not Equals (Ignore Case) NOTINSTALLED
    Write into Text File $LOGGED$ from Value executing MCAbyssInstaller.exe -u -t"$TD$" -c$MCComputerRole$ -d"$DD$" (at end of file)
    Run Program $SUPPORTDIR$\MCAbyssInstaller.exe -u -t"$TD$" -c$MCComputerRole$ -d"$DD$", startup in folder $TARGETDIR$ (WAIT)
  end
   
  Set Variable isMCServiceInstalled to
  Check Service State for MCService (write result into variable isMCServiceInstalled)
  if Variable isMCServiceInstalled not Equals NOTINSTALLED
    Write into Text File $LOGGED$ from Value executing MCServiceInstaller.exe -u -t"$TD$" -c$MCComputerRole$ (at end of file)
    Run Program $SUPPORTDIR$\MCServiceInstaller.exe -u -t"$TD$" -c$MCComputerRole$, startup in folder $TARGETDIR$ (WAIT)
  end
   
  Set Variable isMCMServiceInstalled to
  Check Service State for MCMService (write result into variable isMCMServiceInstalled)
  if Variable isMCMServiceInstalled not Equals NOTINSTALLED
    Write into Text File $LOGGED$ from Value executing MCMServiceInstaller.exe -u -t"$TD$" -c$MCComputerRole$ (at end of file)
    Run Program $SUPPORTDIR$\MCMServiceInstaller.exe -u -t"$TD$" -c$MCComputerRole$, startup in folder $TARGETDIR$ (WAIT)
  end
   
  Unregister assembly Microsoft.ServiceBus, Version=0.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
   
  Apply Uninstall (get result into variable SUCCESS)
  if Variable SUCCESS not Equals ERROR
    if Variable SUCCESS not Equals CANCEL
      Remove Unpinned Assemblies
      if Variable IsWindows64Bit Equals (Ignore Case) TRUE
        Run Program $SUPPORTDIR$\gacutilx64.exe /ul $SUPPORTDIR$\GAC.txt (WAIT)
        else
        Run Program $SUPPORTDIR$\gacutilx32.exe /ul $SUPPORTDIR$\GAC.txt (WAIT)
      end
    end
  end
  Set Variable PROGRESS to 100
  Comment: Next 3 lines seem to be required
  Comment: Hide Dialog
  Comment: Display Dialog: finish, wait for dialog to return (modal)
  Comment: Terminate Installation
end
<<Code Folding Region>>


Everything proceeds as expected and as I understand it, the uninstall process is completed within that region. The uninstallation appears to work OK BUT unfortunately, my installation appears to then proceed with the installation routine and fails of course. Here's the rest of my script (edited to remove repetitive calls):

Code: Select all

[DEFINE REGION: Perform First Time or Maintenance Installation]
Comment: Install/Re-Install product
Create Shortcut $SHORTCUTFOLDER$\Uninstall MyCourts to $UNINSTALLLINK$, run as administrator, do not highlight in Start Menu, do not include in Start Screen, disable user pinning
[OFFLINE CONTENT]
 
label: Registry entries
Comment: ########### Registry
Set Variable PROGRESSTEXT to Checking Registry Entries
Set Variable PROGRESSMODE to MARQUEE
 
Set Variable HKLMExists to FALSE
Check Registry Key HKLM\SOFTWARE\Aquarius Communications\MyCourts\ into HKLMExists
if Variable HKLMExists Equals NO$KEY
  Write Registry Key HKLM\SOFTWARE\Aquarius Communications\MyCourts\,  (permanent)
end
 
Comment: Record the location of the Shared Resources Directory
if Variable MCSharedDataDirectory not Equals
  Set Variable MCDATADIR to $MCSharedDataDirectory$
  Set Variable MCDD to $MCDATADIR$\somenonexistsnat.exe
  Replace \\ with \: MCDD
  Extract File Folder: MCDD
  Parse String $MCDD$ into Variables MCDATADIR and  (Split at last occurrence of pattern)
  Write Registry Key HKLM\SOFTWARE\Aquarius Communications\MyCourts\SharedDataDirectory, $MCDATADIR$ (permanent)
  else
  Comment: $ALLAPPDATA$ has a trailing backslash
  Set Variable MCDATADIR to $ALLAPPDATA$Aquarius Communications\MyCourts\Resources
  Set Variable MCDD to $MCDATADIR$\somenonexistsnat.exe
  Replace \\ with \: MCDD
  Extract File Folder: MCDD
  Parse String $MCDD$ into Variables MCDATADIR and  (Split at last occurrence of pattern)
  Write Registry Key HKLM\SOFTWARE\Aquarius Communications\MyCourts\SharedDataDirectory, $MCDATADIR$ (permanent)
end
 
Comment: Record the location of the Local Resources Directory
Write Registry Key HKLM\SOFTWARE\Aquarius Communications\MyCourts\LocalDataDirectory, $ALLAPPDATA$Aquarius Communications\MyCourts\Resources (permanent)
 
Comment: Record the location of the Data Directory [Will replaced SharedDataDirectory]
Write Registry Key HKLM\SOFTWARE\Aquarius Communications\MyCourts\DataDirectory, $MCDATADIR$ (permanent)
 
Set Variable TDD to $TARGETDIR$\somenonexistsnat.exe
Replace \\ with \: TDD
Extract File Folder: TDD
Parse String $TDD$ into Variables TARGETDIR and  (Split at last occurrence of pattern)
Write Registry Key HKLM\SOFTWARE\Aquarius Communications\MyCourts\AppDirectory, $TARGETDIR$ (permanent)
 
Set Variable MCUseServerDB to
Check Registry Key HKLM\Software\Aquarius Communications\UserServerDB into MCUseServerDB
if Variable MCUseServerDB not Equals NO$KEY
  Read Registry Key HKLM\Software\Aquarius Communications\MyCourts\UseServerDB into MCUseServerDB
  else
  Write Registry Key HKLM\SOFTWARE\Aquarius Communications\MyCourts\UseServerDB, True (permanent)
end
 
Write Registry Key HKLM\SOFTWARE\Aquarius Communications\MyCourts\ComputerRole, $MCComputerRole$ (permanent)
 
if Variable ALLUSERS Equals TRUE
  Write Registry Key HKLM\SOFTWARE\Aquarius Communications\MyCourts\AllUsers, 1 (permanent)
end
 
Apply Install (get result into variable SUCCESS)
Write into Text File $LOGGED$ from Value Applly Install Line 561 returned = $SUCCESS$ (at end of file)
 
Set Variable CompletedPermissions to FALSE
Set Variable SetPermissionsResult to
Set Variable TDD to $TARGETDIR$\nonexist.exe
Replace \\ with \: TDD
Extract File Folder: TDD
Parse String $TDD$ into Variables TARGETDIR and  (Split at last occurrence of pattern)
Run Program $SUPPORTDIR$\SetPermissions.exe "$TARGETDIR$"
Write into Text File $LOGGED$ from Value SetPermissions returned = $SetPermissionsResult$ (at end of file)
Apply Install (get result into variable CompletedPermissions)
Write into Text File $LOGGED$ from Value Applly Install Line 572 returned = $SUCCESS$ (at end of file)
Write into Text File $LOGGED$ from Value SetPermissions returned $CompletedPermissions$ (at end of file)
 
Set Variable PROGRESSTEXT to Installing $TITLE$ Program files.
Write into Text File $LOGGED$ from Value Install Files: TARGETDIR = $TARGETDIR$ (at end of file)
Write into Text File $LOGGED$ from Value Install Files: MCDATADIR = $MCDATADIR$ (at end of file)
 
Install Files D:\IADistributions\MyCourts\help.ico to $TARGETDIR$

Install Files D:\IADistributions\MyCourts\subinacl.exe to $TARGETDIR$
 
Set Variable PROGRESSTEXT to Creating Shortcuts
label: Create Shortcuts
Create Shortcut $SHORTCUTFOLDER$\MyCourts to $TARGETDIR$\MyCourts.exe
Create Shortcut $SHORTCUTFOLDER$\MyCourts Help to $TARGETDIR$\MyCourts.chm, Pin to Start Screen
Create Shortcut $SHORTCUTFOLDER$\MyCourts Reports to $TARGETDIR$\MyCourtsReports.exe
Create Shortcut $SHORTCUTFOLDER$\MyCourts Manager to $TARGETDIR$\MCManager.exe, Pin to Start Menu, Pin to Start Screen
Create Shortcut $DESKTOPDIR$\MyCourts Manager to $TARGETDIR$\MCManager.exe, Pin to Start Menu, Pin to Start Screen
Create Shortcut $SHORTCUTFOLDER$\MyCourts Check for Updates to $TARGETDIR$\MCCheckForUpdates.exe, run as administrator
if Variable Client not Equals (Ignore Case) TRUE
  Create Shortcut $SHORTCUTFOLDER$\MyCourts Administrator to $TARGETDIR$\MyCourtsAdmin.exe, run as administrator
  Create Shortcut $SHORTCUTFOLDER$\MyCourts Support to $TARGETDIR$\MCSupport.exe
end
 
if Variable Client not Equals (Ignore Case) TRUE
  Set Variable PROGRESSTEXT to Installing $TITLE$ Database Files
  Install Files D:\IADistributions\MyCourts\chimes.wav to $MCDATADIR$
  Install Files D:\IADistributions\MyCourts\MyCourtsUserLog.vdb4 to $MCDATADIR$ (Permanent, Never Overwrite)
end
 
Write Registry Key HKLM\SYSTEM\CurrentControlSet\services\MCService\AppDirectory, $TARGETDIR$
Write Registry Key HKLM\SYSTEM\CurrentControlSet\services\MCService\ComputerRole, $MCComputerRole$
Write Registry Key HKLM\SYSTEM\CurrentControlSet\services\MCService\LocalDataDirectory, $ALLAPPDATA$Aquarius Communications\MyCourts\ResourcesWrite Registry Key HKLM\SYSTEM\CurrentControlSet\services\MCService\DBPath, $MCDATADIR$
Write Registry Key HKLM\SYSTEM\CurrentControlSet\services\MCMService\AppDirectory, $TARGETDIR$
Write Registry Key HKLM\SYSTEM\CurrentControlSet\services\MCMService\ComputerRole, $MCComputerRole$
Write Registry Key HKLM\SYSTEM\CurrentControlSet\services\MCMService\LocalDataDirectory, $ALLAPPDATA$Aquarius Communications\MyCourts\ResourcesWrite Registry Key HKLM\SYSTEM\CurrentControlSet\services\MCMService\DBPath, $MCDATADIR$
 
Install Files D:\IADistributions\MyCourts\MCUpdateClient.exe.config to $TARGETDIR$
Install Files D:\IADistributions\MyCourts\ShowHelp.exe to $TARGETDIR$
[DEFINE WEB MEDIA Language Files, Exclude from Build]
Get Component Language Files Selection State into Variable SELECTED
if Variable SELECTED Equals TRUE
end
[DEFINE WEB MEDIA POS for .Net, Exclude from Build]
Get Component POS for .Net Selection State into Variable SELECTED
if Variable SELECTED Equals TRUE
end
[DEFINE WEB MEDIA New Feature, Exclude from Build]
if Variable SELECTED Equals TRUE
end
[OFFLINE CONTENT]
Get Component MyCourts 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
  Create Folder $TARGETDIR$\webserver
  Create Folder $TARGETDIR$\webserver\htdocs
  Create Folder $TARGETDIR$\bin
  Comment: Set Variable CommonDocuments to
  Comment: Read Registry Key HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Folders\Common Documents into CommonDocuments
  Comment: Create Folder $CommonDocuments$\MyCourts
   
  if Variable Client not Equals (Ignore Case) TRUE
    Set Variable PROGRESSTEXT to Installing $TITLE$ Database files [Not advertised]
    Create Folder $MCDATADIR$\MemberNotes
    Create Folder $MCDATADIR$\Semaphores
    Write into Text File $MCDATADIR$\Semaphores\alertCloseDBConnections.sema4 from Value Installation in progress (at end of file)
  end
   
  Set Variable PROGRESSTEXT to Installing $TITLE$ Assemblies
  Install Assembly D:\IADistributions\MyCourts\DLL's\nsoftware.IPWorks.dll to Global Assembly Cache
  Install Assembly D:\IADistributions\MyCourts\DLL's\MCWCFService.dll to Global Assembly Cache
   
   
  Set Variable PROGRESSTEXT to Installing files
  Comment: Apply Install
  Apply Install (get result into variable SUCCESS)
   
  Set Variable PROGRESSTEXT to Installing services
   
  Set Variable TD to
  Set Variable TDD to $TARGETDIR$\nonexist.exe
  Replace \\ with \: TDD
  Comment: Write into Text File $LOGGED$ from Value TDD = $TDD$ (at end of file)
  Extract File Folder: TDD
  Comment: Write into Text File $LOGGED$ from Value TDD = $TDD$ (at end of file)
  Parse String $TDD$ into Variables TD and  (Split at last occurrence of pattern)
  Write into Text File $LOGGED$ from Value TDD = $TDD$ and hence TD = $TD$ (at end of file)
  Set Variable DD to
  Set Variable DDD to $MCDATADIR$\Noexist.exe
  Replace \\ with \: DDD
  Extract File Folder: DDD
  Parse String $DDD$ into Variables DD and  (Split at last occurrence of pattern)
   
  Comment: MessageBox: Debug, running MCInstallUtility
  Write into Text File $LOGGED$ from Value executing MCInstallUtility.exe -i -t"$TD$" -c$MCComputerRole$ -d"$DD$" (at end of file)
  Run Program $SUPPORTDIR$\MCInstallUtility.exe -i -t"$TD$" -c$MCComputerRole$ -d"$DD$", startup in folder $TD$ (WAIT)
  if Variable Server Equals (Ignore Case) TRUE
    Set Variable SmartInspectRouter to
    Check Service State for SmartInspectRouter (write result into variable SmartInspectRouter)
    if Variable SmartInspectRouter not Equals (Ignore Case) NOTINSTALLED
      Set Variable PROGRESSTEXT to Start SmartInspect Router
      if Variable SmartInspectRouter Equals STOPPED
        Run Program net start SmartInspectRouter (WAIT)
      end
    end
  end
   
   
  if Variable Client not Equals (Ignore Case) TRUE
    Does File Exist $TARGETDIR$\MCService.exe (get result into variable MCServiceExists)
    Write into Text File $LOGGED$ from Value MCService.exe exists = $MCServiceExists$ (at end of file)
    Write into Text File $LOGGED$ from Value executing MCServiceInstaller.exe -i -t"$TD$" -c$MCComputerRole$ (at end of file)
    Run Program $SUPPORTDIR$\MCServiceInstaller.exe -i -t"$TD$" -c$MCComputerRole$, startup in folder $TARGETDIR$ (WAIT)
    Set Variable MCServiceState to
    Check Service State for MCService (write result into variable MCServiceState)
    if Variable MCServiceState not Equals (Ignore Case) NOTINSTALLED
      Set Variable PROGRESSTEXT to Start MCService
      if Variable MCServiceState Equals STOPPED
        Run Program net start MCService (WAIT)
      end
    end
     
    Write into Text File $LOGGED$ from Value executing MCMServiceInstaller.exe -i -t"$TD$" -c$MCComputerRole$ (at end of file)
    Run Program $SUPPORTDIR$\MCMServiceInstaller.exe -i -t"$TD$" -c$MCComputerRole$, startup in folder $TARGETDIR$ (WAIT)
    Set Variable MCMServiceState to
    Check Service State for MCMService (write result into variable MCMServiceState)
    if Variable MCMServiceState not Equals (Ignore Case) NOTINSTALLED
      Set Variable PROGRESSTEXT to Start MCMService
      if Variable MCMServiceState Equals STOPPED
        Run Program net start MCMService (WAIT)
      end
    end
     
    Write into Text File $LOGGED$ from Value executing MCAbyssInstaller.exe -i -t"$TD$" -c$MCComputerRole$ -d"$DD$" (at end of file)
    Run Program $SUPPORTDIR$\MCAbyssInstaller.exe -i -t"$TD$" -c$MCComputerRole$ -d"$DD$", startup in folder $TARGETDIR$ (WAIT)
    Set Variable MCAbyssState to
    Check Service State for AbyssWebServer (write result into variable MCAbyssState)
    if Variable MCAbyssState not Equals (Ignore Case) NOTINSTALLED
      Set Variable PROGRESSTEXT to Start Abyss Web Server
      if Variable MCAbyssState Equals STOPPED
        Run Program net start AbyssWebServer (WAIT)
      end
    end
  end
   
   
  if Variable REMOVE Equals FALSE
    if Variable Client not Equals (Ignore Case) TRUE
      Set Variable PROGRESSTEXT to Checking / Updating database
      Run Program $TARGETDIR$\MyCourtsUpdate.exe , startup in folder $TARGETDIR$ (WAIT)
      Does File Exist $MCDATADIR$\Semaphores\alertCloseDBConnections.sema4 (get result into variable FileExists)
      if Variable FileExists Equals (Ignore Case) TRUE
        Delete Files $MCDATADIR$\Semaphores\alertCloseDBConnections.sema4 (when installing and uninstalling)
      end
    end
  end
   
   
   
   
  if Variable SUCCESS not Equals ERROR
    if Variable SUCCESS not Equals CANCEL
      Comment: Grant Complete Access to File System Object "$ALLAPPDATA$\Aquarius Communications\MyCourts\Resources\*.*"
      Comment: Grant Complete Access to File System Object "$MCDATADIR$"
      Register assembly Microsoft.ServiceBus, Version=0.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
      Comment: Grant Complete Access to Registry Key "HKEY_LOCAL_MACHINE\SOFTWARE\Aquarius Communications\MyCourts"
      Comment: Grant Complete Access to File System Object "$TARGETDIR$"
    end
     
    Set Variable PROGRESSTEXT to Updating firewall rules
     
    Set Variable UserOSVersion to
    Get Exact OS Level into UserOSVersion
    if Variable UserOSVersion Equals XP
      Run Program netsh firewall delete allowedprogram "$TARGETDIR$\MyCourtsAdmin.exe"
      Run Program netsh firewall add allowedprogram"$TARGETDIR$\MyCourtsAdmin.exe" "MyCourts Administrator" ENABLE
      Run Program netsh firewall delete allowedprogram "$TARGETDIR$\MyCourts.exe"
      Run Program netsh firewall add allowedprogram"$TARGETDIR$\MyCourts.exe" "MyCourts" ENABLE
      Comment: Run Program netsh firewall delete allowedprogram "$TargetDir$\MCService.exe"
      Comment: Run Program netsh firewall add allowedprogram"$TargetDir$\MCService.exe" "MCService" ENABLE
      Comment: if Variable Client not Equals (Ignore Case) TRUE
      Comment: Run Program netsh firewall add allowedprogram"$TargetDir$\webserver\abyssws.exe ENABLE
      Comment: end
      else
      Run Program netsh advfirewall firewall delete rule name="MyCourts Administrator" program="$TARGETDIR$\MyCourtsAdmin.exe"
      Run Program netsh advfirewall firewall add rule name="MyCourts Administrator" dir=out action=allow program="$TARGETDIR$\MyCourtsAdmin.exe" enable=yes
      Run Program netsh advfirewall firewall delete rule name="MyCourts" program="$TARGETDIR$\MyCourts.exe"
      Run Program netsh advfirewall firewall add rule name=MyCourts dir=out action=allow program="$TARGETDIR$\MyCourts.exe" enable=yes
      Comment: Run Program netsh advfirewall firewall delete rule name="MCService" program="$TargetDir$\MCService.exe"
      Comment: Run Program netsh advfirewall firewall add rule name=MCService dir=out action=allow program="$TargetDir$\MCService.exe" enable=yes
      Comment: if Variable Client not Equals (Ignore Case) TRUE
      Comment: Run Program netsh advfirewall firewall add rule name=AbyssWebServer dir=out action=allow program="$TargetDir$\webserver\abyssws.exe" enable=yes
      Comment: end
    end
  end
end
 
 
[compiler end]
Set Variable PROGRESS to 100
Comment: end
<<Code Folding Region>>
<<Code Folding Region>>
 
[DEFINE REGION: Finish Setup]
Comment: End of Installation
Set Variable runMCManager to False
Hide Dialog
Display Dialog: finish, wait for dialog to return (modal)
if Variable SILENT Equals FALSE
  if Variable REBOOTCOMPUTER Equals TRUE
    if Variable SUCCESS Equals REBOOT
      Reboot Computer
    end
  end
  Comment: TO-DO: Insert command that starts your application here
  if Variable REMOVE Equals FALSE
    if Variable SUCCESS Equals COMPLETE
      Run Program $EXEFILE$ /updatesetup /s
      Comment: Run Program hh.exe mk:@MSITStore:$TARGETDIR$\MyCourts.chm::/MCManager.htm
      Comment: Run Program $TARGETDIR$\MCManager.exe -i
      Run Program ShowHelp.exe , startup in folder $TARGETDIR$
    end
  end
end
<<Code Folding Region>>
 


It seems to me that:

Comment: Next 3 lines seem to be required
Comment: Hide Dialog
Comment: Display Dialog: finish, wait for dialog to return (modal)
Comment: Terminate Installation


should be commented in but I've looked at the samples supplied with the distribution and they don't have any such directives.

I'm using the Native Engine if that matters.

Thanks.

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

Re: Uninstall script logic

Postby FrancescoT » Thu Jul 02, 2015 1:39 pm

Dear Glen,

Honestly, I am not able to see which could be the problem by the code you posted.

Could you post a very minimal project that replicates the issue?

A question, do you run the uninstall from Add Remove Program (control Panel)?

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

glenharvy
Posts: 167
Joined: Fri Sep 14, 2007 3:53 am

Re: Uninstall script logic

Postby glenharvy » Thu Jul 02, 2015 6:22 pm

The issue happens when I run it from Add/Remove program or the new IA Installer attempts it.

A bit more background...
My goal is to commence using the Native Engine however I don't know for certain what version/engine the end user has currently installed.
I read in a post somewhere that you can't uninstall a Native Engine installation without using the Native Engine and the same rule applies to the non-native setup. Doing so (if it is possible) will require the end user to use Add/Remove programs manually.

Frankly, at the time, I thought that the "new" IA Installer actually did the uninstall of the previous version but I now believe that is not the case. I think the "new" IA Installer just triggers the "previous" IA Installer to run the uninstallation script and sets $REMOVE$ to true.

Keeping the above in mind I created a variable $PERFORMUPGRADE$ and set the vale true or false as follows:

Code: Select all

 if Variable RECOMMENDEDUPGRADE Equals TRUE
   Set Variable PERFORMUPGRADE to TRUE
   Set Variable NATIVE_ENGINE to TRUE
 end
 
 if Variable NEEDSUPGRADE Equals TRUE
   Set Variable NATIVE_ENGINE to FALSE
   Set Variable PERFORMUPGRADE to TRUE
 end


I then call the Remove function as follows:

Code: Select all

   if Variable PERFORMUPGRADE Equals TRUE
     Set Variable REMOVEOLD to
     Set Variable ERROROLD to
     
     Set Variable isAbyssWebServerInstalled to
     Check Service State for AbyssWebServer (write result into variable isAbyssWebServerInstalled)
     if Variable isAbyssWebServerInstalled not Equals NOTINSTALLED
       Run Program NET STOP AbyssWebServer
     end
     
     Set Variable isMCServiceInstalled to
     Check Service State for MCService (write result into variable isMCServiceInstalled)
     if Variable isMCServiceInstalled not Equals NOTINSTALLED
       Run Program NET STOP MCService
     end
     
     Set Variable MCManagerClosed to
     Safely Terminate Process "mcmanager.exe", get result into variable MCManagerClosed
     if Variable MCManagerClosed Equals (Ignore Case) FALSE
       Terminate Program MCManager
     end
     
     Set Variable isMCMServiceInstalled to
     Check Service State for MCMService (write result into variable isMCMServiceInstalled)
     if Variable isMCMServiceInstalled not Equals NOTINSTALLED
       Run Program NET STOP MCMService
     end
     
     Comment: The following executes the MSI code to uninstall the previous version
     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$.$NEWLINE$Please uninstall it yourself by using Control Panel  - Add-Remove Programs before attempting to update/install this product.$NEWLINE$$NEWLINE$$ERROROLD$$NEWLINE$
       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
     Set Variable NATIVE_ENGINE to TRUE
     else
     Set Variable NATIVE_ENGINE to TRUE
     
   end


As I said, I now believe that

Code: Select all

     Install/Remove MSI Package $PRODUCTCODE$[REMOVE=ALL] (get result into variable REMOVEOLD)

calls the previous IA Installer to perform the uninstall so the above logic is not necessary. It won't do any harm so I have left it in for now.

OK. So now we move on to the actual installation that is performed by the "new" IA Installer.
The code is in my previous post and I don't believe there is any difference between the "new" and all my previous IA Installers although I will of course check this in early course but see below**. It is certainly the same in the immediate past IA Installer because that's how I discovered this situation. I received the message to uninstall it manually and that's what I did. It then uninstalled OK but then immediately carried on with the script as of course it should. Cancelling that installation actually cleared the problem because it had already been uninstalled.

I have added the following to my REMOVE section and the uninstall and install processing works fine:

Code: Select all

   Comment: Next 3 lines seem to be required
   Hide Dialog
   Display Dialog: uninstallFinish, wait for dialog to return (modal)
   Terminate Installation


So that we have a common project to work on, lets use the DefaultProject in the Samples folder (I am on version 18):

Code: Select all

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]
  Comment: Install/Re-Install product
  Create Shortcut $SHORTCUTFOLDER$\Uninstall #TITLE# to $UNINSTALLLINK$
  [OFFLINE CONTENT]
  [DEFINE WEB MEDIA $$$]
  Get Component $$$ 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>>
 
<<Code Folding Region>>
Comment: End of Installation
Hide Dialog
Display Dialog: finish, wait for dialog to return (modal)
if Variable SILENT Equals FALSE
  if Variable REBOOTCOMPUTER Equals TRUE
    if Variable SUCCESS Equals REBOOT
      Reboot Computer
    end
  end
  if Variable RUNAPP Equals TRUE
    if Variable REMOVE Equals FALSE
      if Variable SUCCESS Equals COMPLETE
        Comment: TO-DO: Insert command that starts your application here
      end
    end
  end
end
<<Code Folding Region>>


I can't see why in your DefaultProject that after performing the REMOVE it will not keep going and perform Apply Install.

So I now think I know what my problem is and I think I have already fixed it by terminating the script within the REMOVE region. Is there any reason that I'm not yet aware of why I should not terminate the script in that fashion. If there is then please let me know.

** I actually call Apply Install before the following code is called:

Code: Select all

  [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]

I do not surround my Apply Install with the [compiler] directives. I only started calling Apply Install in addition to the above code in my last IA Installer.

InstallAware.zip
mpr attached
(50.19 KiB) Downloaded 343 times

Thanks.

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

Re: Uninstall script logic

Postby FrancescoT » Fri Jul 03, 2015 2:31 pm

Dear Glen,

for what you are reporting, I believe it exists a misunderstanding about NATIVE ENGINE functionality.

When switching from MSI engine to a Native engine, regarding the Whole un-install process, there isn't any particular step to take.
All is already done and ready to use as required.

To demonstrate this, just follow these simple steps;

1 - create a new project from scratch from basic template and leave all project settings/properties as they are by default.
2 - build the project.
3- Install the generated setup package on a target machine.

Please note that the above project is by default a MSI engine project ... we leaved all default settings.

4 - Now Switch the project we just created to Native engine.
To make this possible define the following statement at the very beginning of the main script code:
> Set Variable NATIVE_ENGINE to TRUE

5 - Rebuild the project (you may change the product version before to build the project)
6 - Run the new generated "native engine" setup package on the same target where you installed the previous build.

Finally, you will see that the already installed package will be first removed before to proceed to install the new one.

That said, the Native engine is able to detect if a based MSI engine installation (for the same product = same PRODUCTCODE) is already installed.
Unfortunately, it's not possible the contrary by default. Due the fact that the MSI engine doesn't know of the IA NATIVE engine existence.

Anyway, it's always possible to store a "data" on target machine in order to detect from a MSI based engine, the presence of Native Engine installations on target machine.

However, it could also preferable to distinguish between product deployed using the different engines and at this purpose, you may use different PRODUCT codes. Of course, using this approach the installed applications will coexist.


Hope this helps you.

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

glenharvy
Posts: 167
Joined: Fri Sep 14, 2007 3:53 am

Re: Uninstall script logic

Postby glenharvy » Fri Jul 03, 2015 4:41 pm

Thanks for the clarification and I understand what you say.

Please now forget about the native engine/msi issue and focus on the following:

WHY DOES IA INSTALLER TERMINATE AFTER PERFORMING A REMOVE AND NOT JUST CONTINUE ON WITH THE SCRIPT?

In the DefaultProject example, there is no termination instruction between the end of the REMOVE section and the Apply Install section:

Code: Select all

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]
  Comment: Install/Re-Install product
  Create Shortcut $SHORTCUTFOLDER$\Uninstall #TITLE# to $UNINSTALLLINK$
  [OFFLINE CONTENT]
  [DEFINE WEB MEDIA $$$]
  Get Component $$$ 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>>


I am assuming IA Installer executes the code in the REMOVE region when it responds to the Delete option in Maintenace which is displayed when you chose uninstall via the Control Panel Add/Remove programs link. Perhaps this is where I am wrong!!!

In a non-Native Engine setup:
Perhaps "Apply Uninstall" just calls MSI to uninstall the program and immediately terminates.

In a Native Engine setup:
Perhaps "Apply Uninstall" calls MSI to uninstall the program, waits for completion and then proceeds with the script.

At least that is how it appears to me. Is that correct?

glenharvy
Posts: 167
Joined: Fri Sep 14, 2007 3:53 am

Re: Uninstall script logic

Postby glenharvy » Mon Jul 06, 2015 4:37 am

I think I found my problem - I have an end rather than an else after the REMOVE.

Please confirm that when using the Native Engine, Apply Install doesn't first require a previous Native Engine installation to be removed.

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

Re: Uninstall script logic

Postby FrancescoT » Mon Jul 06, 2015 12:26 pm

Dear Glen,

the variable RECOMMENDEDUPGRADE indicates whether a previous version of the product installed with the native engine has been detected (and its removal is recommended).

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

glenharvy
Posts: 167
Joined: Fri Sep 14, 2007 3:53 am

Re: Uninstall script logic

Postby glenharvy » Mon Jul 06, 2015 5:37 pm

I know I'm dumb but I just need to confirm whether the following is true or false:

1. When using the NATIVE ENGINE there is no need to call "Apply Uninstall" if you are processing in effect an UPGRADE. The NATIVE ENGINE will detect the prior
version automatically (given the same Product GUID).

2. When using the NATIVE ENGINE you only call "Apply Uninstall" if you actually need to remove the program (for example - in the REMOVE) block.

Thank you.

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

Re: Uninstall script logic

Postby FrancescoT » Tue Jul 07, 2015 2:01 pm

Dear Glen,

yes, they are both TRUE.

Please also a look, if you haven't already, at the the description available for "DELAYUNTIL_APPLYCHANGES" pre-defined variable.

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

glenharvy
Posts: 167
Joined: Fri Sep 14, 2007 3:53 am

Re: Uninstall script logic

Postby glenharvy » Tue Jul 07, 2015 5:04 pm

Thank you for your help and assistance.

I believe I now know what I'm doing :D

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

Re: Uninstall script logic

Postby FrancescoT » Wed Jul 08, 2015 11:11 am

: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


Return to “Technical Support”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 107 guests