Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

How to automate uninstall before install new ver?


8 replies to this topic

kcheung

kcheung
  • Full Members
  • 4 posts

Posted 26 October 2012 - 17:30

I am running IS 2012 Pro and have a InstallScript project (non-MSI) for one of our software products. We are currently rolling out a new version and I would like the installer to be able to automatically detect an existing version, and be able to uninstall it prior to installing the new version. Currently, the set up is that when the user clicks on setup.exe, the installer will see the old version and prompt the user to uninstall. Once the uninstall is completed, the user will have to click on setup.exe again to install the new version of the software.

Facts about the installer:
- We have been using the same GUID for several releases, and would like to continue to use the same GUID if possible.
- Our software install only allows a single instance on the target system, and thus the need to uninstall first.

What I want to updated installer to do:

1. User runs setup.exe
2. If no existing version on system, just proceed like normal fresh install.
3. If a version of software exists on system, user will be prompted that the old version will be removed.
4. When user agrees to continue, installer will remove the old version, and then install the new version as new.

I know that for MSI projects, there is the upgrade feature that may achieve this. But I am not aware that similar feature exists for non-MSI projects.

Please advice.

Thanks in advance.

Kenny



Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 28 October 2012 - 15:50

You could read the uninstall command from registry and execute it.

kcheung

kcheung
  • Full Members
  • 4 posts

Posted 30 October 2012 - 20:19

Thanks Stefan. I tried to do so using LaunchAppAndWait but was not successful. Here is my UninstallSetup code:

CODE

function UninstallSetup(szOldKey)      

STRING szKey, svValue, szUninstValue, firststring, svString, secondstring;
NUMBER nvSize, nType, nResult, numResult;
LIST listID;

begin
 nType = REGDB_NUMBER;
 szUninstValue = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{" + szOldKey + "}";
 RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);

 // Retrieve the uninstallation string.
 if (RegDBGetKeyValueEx(szUninstValue, "UninstallString", nType, svValue, nvSize) == 0) then    
  if (AskYesNo("Uninstall old version?", YES) = NO) then    
   MessageBox ("Installation will be aborted.", SEVERE);
   exit;
  endif;
   
  listID = ListCreate ( STRINGLIST );
  StrGetTokens ( listID , svValue , "\"" );
  nResult = ListGetFirstString (listID, svString);
  firststring = svString;

  // Loop while list items continue to be retrieved.
  while (nResult != END_OF_LIST)

    // Get the next string in the list.
    nResult = ListGetNextString (listID, svString);
    numResult = StrFind ( svString , "setup.exe" );
    if (numResult > 0)then
       secondstring = svString;
    endif;
  endwhile;
  LongPathToQuote ( firststring , TRUE );
  LongPathToQuote ( svString , TRUE );
  if (LaunchAppAndWait (firststring, svString, LAAW_OPTION_WAIT) < 0) then
     MessageBox("Failed to Remove the Application", SEVERE);
  endif;
 endif;
end;          


During debug, I can see that the command going into LaunchAppAndWait are:

firststring is "C:\Program Files (x86)\InstallShield Installation Information\{362A1E21-4571-43BC-8846-93B9913D46CE}\setup.exe"

svString is " -runfromtemp -l0x0409 -removeonly"

Any idea why LaunchAppAndWait fails? BTW, I am now using a new GUID for the new version.

Thanks.

Kenny

Edited by kcheung, 30 October 2012 - 20:19.


Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 31 October 2012 - 13:42

As a cross check, what happens if you manually invoke that same uninstall command from the Command Prompt?

Also, as I stated the other day over here, I've always just used WAIT instead of LAAW_OPTION_WAIT for LaunchAppAndWait()'s nOptions parameter though, so I would try that instead.

If you still have problems, then you can also check the value of LAAW_PARAMETERS.nLaunchResult for the launched application's error code.
user posted image

kcheung

kcheung
  • Full Members
  • 4 posts

Posted 01 November 2012 - 00:43

Taco Bell - turns out for some reason the setup.exe is missing from the Install Shield Information folder on my test system, and thus the error.

Now that I have it working, I want to know if there is a way to silent uninstall. For instance, at the end of my uninstall, I would prompt the user to choose whether to reboot or not. But in this case I want to uninstall and continue with the session without prompting to reboot.

Any idea how to do so?

Thanks.

Kenny

Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 01 November 2012 - 12:51

To silently uninstall, try using the switches " -clone_wait -hide_progress -hide_splash" in addition to -or- instead of the ones you retrieve from the original uninstall string.
user posted image

kcheung

kcheung
  • Full Members
  • 4 posts

Posted 02 November 2012 - 21:56

Thanks Taco Bell. Your suggestion, in combination with defining a setup.iss file, allows me to silently uninstall the old versions.

Kenny

Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 05 November 2012 - 13:25

You're welcome kcheung and glad you got it working.
user posted image

maddy

maddy
  • Full Members
  • 3 posts

Posted 07 August 2013 - 18:39

I am trying to do exactly what you asked but with the same GUID for all releases. Is there any way to do so? 

 

kcheung

        Why did u change ur strategy to have different GUID? Any specific reason ?