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

Uninstalling a previous version


3 replies to this topic

kvsasi

kvsasi
  • Members
  • 8 posts

Posted 28 May 2003 - 13:51

Hello,

I am trying to uninstall a previous version of my program when users try to install. I used ComponentRemoveAll() to uninstall the old version and then installed the new version by ComponentReinstall(). The installation works fine but my program doesn't appear in the Windows control panel's Add/Remove programs dialog.


What am I doing wrong?


Code:
// Store the currently selected items in a list because
// ComponentRemoveAll will unselect them
listCompList = ListCreate (STRINGLIST);
ComponentListItems (MEDIA, "", listCompList);
nResult = ListGetFirstString ( listCompList, svComponent );
listSelectedCompList = ListCreate(STRINGLIST);
while ( nResult != END_OF_LIST )
nSelected = ComponentIsItemSelected (MEDIA, svComponent);
if(nSelected) then
ListAddString (listSelectedCompList, svComponent, AFTER);
endif;
nResult = ListGetNextString (listCompList, svComponent);
endwhile;
ComponentRemoveAll();

// Enable progress indicator.
Enable(STATUSOLD);
// Set the limit of the progress bar to 100% completion.
StatusUpdate (ON, 100);
// Set the progress bar to 0% and display a message.
SetStatusWindow (0, "Uninstalling the previous version");
nResult = ComponentTransferData(MEDIA);

// Set the component selections from the list obtained before
// ComponentRemoveAll
nResult = ListGetFirstString ( listSelectedCompList, vComponent );
while ( nResult != END_OF_LIST )
ComponentSelectItem (MEDIA, svComponent, TRUE);
nResult = ListGetNextString (listSelectedCompList, svComponent);
endwhile;
ComponentReinstall();



Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 28 May 2003 - 17:01

Well the Add/Remove Program entry is usually written by the OnMoving event which is in turn called by ComponentTransferData. However, you only call this method to remove and not to reinstall, so this is why the ARP entry is probably missing. Therefore try adding the following line to the end of this code:
nResult = ComponentTransferData(MEDIA);


user posted image

kvsasi

kvsasi
  • Members
  • 8 posts

Posted 09 June 2003 - 16:29

TacoBell00,

I didn't think adding

nResult = ComponentTransferData(MEDIA);

after ComponentReinstall() will help because, I am calling ComponentReinstall() in OnMaintUIBefore and ComponentTransferData(MEDIA) gets called automatically after OnMaintUIBefore.

I did test after adding ComponentTransferData(MEDIA) to confirm my thought and I do get the same problem.





Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 10 June 2003 - 01:26

Oh, you didn't mention this was being done in OnMaintUIBefore, but that's not too surprising.

In that case, you can probably resolve your problem by making the following call at the very end of OnMaintUIBefore to (re)create the Add/Remove program entry:
MaintenanceStart();

Normally this function is automatically called after the OnFirstUIBefore event, but of course you're not doing that event here. Check the help file for more information on this function.

---

To be honest though, I don't really agree with your approach. If you're requiring the old installation to be removed, for whatever reason, then your new installation should have a different project GUID. That way you can simply call the old uninstall command before installing this new version, and the two won't interfere with one another as we're seeing here.
user posted image