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 automatically uninstall a previous version?


3 replies to this topic

honery

honery
  • Members
  • 6 posts

Posted 25 February 2005 - 06:56

Hello ,

Who could tell me how to automatically uninstall a previous version of a application during installing the latest version of the same application?

I used InstallShield 10.5 Professional packed 2 versions of my applications (e.g. V1.0 and V2.0) using InstallScript project. Firstly, I installed V1.0 on my host. And then I want to install V2.0 on my host. But I don't want to manually remove the application of V1.0 before I start installing V2.0. But I hope the setup program can help me detect the existence of v1.0 and automatically uninstall it before running the installation. The uninstalling process should be silently done by InstallShield Wizard itself and don’t need any user’s response for confirming. After uninstalling the existed application V1.0, the InstallShiled Wizard is supposed to automatically start installing application V2.0 as well as without any user’s confirmation.

I want to use InstallScript to achieve this goal. In event function OnResumeUIBefore I used Buit-in function UninstallApplication. But it doesn't work at all. Because function UninstallApplication() doesn't support the product GUID of the current setup(i.e. uninstall the same product). Anyway my two InstallShield packed applications both belong to the same product family (both have the same product GUID), but different versions.

Are there some approaches that can achieve the goal described above since I think this requirement is very common for updating installation issues?


Any help will be appreciated.
Thxs,

Honery.


honery

honery
  • Members
  • 6 posts

Posted 25 February 2005 - 06:57

Wincor Reply:
----------------------

Hi,

I had the same problems and (due to a lack of a better way to do) used the following as a work-around:

- deregister the files in self-registering groups (when installing, I write a list to the installation directory with all files being registered by InstallShield)
- delete all directories
- install new version

I know that this is not a clean uninstall, but until today the only way I know to solve the problem of silently uninstalling before installing a newer version.

Ciao
Wincor

honery

honery
  • Members
  • 6 posts

Posted 25 February 2005 - 06:58

Anyway in such case this is a practical solution.
But when I install v2.0 of my application to a host in which v1.0 existed, the InstallShield Wizard always leads to Resume installation Mode(Update mode).
Do you mean that I should deregister,delete all existent directories and files in event function OnResumeUIBefore and afterward the setup process can successfully complete?

ifthenelse

ifthenelse
  • Members
  • 10 posts

Posted 19 April 2005 - 06:55

I can help you, I think.
you try the following:

// Get uninstall command from registry

RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
szKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + szAppName;
if ( RegDBGetKeyValueEx(szKey, "UninstallString", nvType, svUninstallString, nvSize) != 0 ) then
svUninstallString = "";
endif;

if ( svUninstallString = "" ) then
return 0;
endif;
// Parse command

StrSub(szTemp, svUninstallString, 0, 1);
if ( szTemp = "\"" ) then

// Path to isuninst.exe is quoted: split after closing quote

StrSub(szTemp, svUninstallString, 1, StrLength(svUninstallString) - 1); // remove opening quote
nPos = StrFind(szTemp, "\""); // search closing quote
if ( nPos < 0 ) then
// MessageBox("Error in uninstall string.", WARNING);
return -1;
endif;
StrSub(szProgram, szTemp, 0, nPos);
StrSub(szCmdLine, szTemp, nPos + 2, StrLength(szTemp) - nPos - 2);
else

// Path is not quoted: split at first blank

nPos = StrFind(svUninstallString, " ");
if ( nPos < 0 ) then
// MessageBox("Error in uninstall string.", WARNING);
return -2;
endif;
StrSub(szProgram, svUninstallString, 0, nPos);
StrSub(szCmdLine, svUninstallString, nPos + 1, StrLength(svUninstallString) - nPos - 1);
endif;
if ( LaunchAppAndWait(szProgram, szCmdLine, WAIT) < 0 ) then
// MessageBox("Failed to launch uninstall.", WARNING);
return -3;
endif;

return 0;

In a word, you can first get the UninstallString from the registry and then try to launch it. That's easy, you can try.

Edited by ifthenelse, 19 April 2005 - 07:00.