cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
_Oscar_
Level 3

"Files in use" dialog box by second msiexec on uninstall previous version

I have an MSI Installscript project that uninstalls the previous version using "UninstallApplication". I paste code sample here:


nReturn = UninstallApplication ( "InstallShield_" + svValue, "/removeonly", LAAW_OPTION_WAIT|LAAW_OPTION_SET_BATCH_INSTALL ); //where svValue is the product GUID I want to unistall


The problem is that UninstallApplication will not wait for Setup.exe to complete the uninstallation of previous version. This is a risk I want to avoid.

So, I tried this:

nReturn = UninstallApplication ( "InstallShield_" + svValue, "", LAAW_OPTION_WAIT_INCL_CHILD );


and the uninstallation of previous version never ends 🙂

And then, I tried this: (I know /SMS should be implicit in Installscript MSI Projects... but...)


nvType = REGDB_STRING;
svValue2="";
nvSize=-1;
szKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall" ^ "InstallShield_" + svValue;
RegDBGetKeyValueEx( szKey, "UninstallString", nvType, svValue2, nvSize );
MessageBox("Before LaunchAppAndWait",INFORMATION);
//This is a test for previous version only...
svValue2 = "C:\\Program Files\\InstallShield Installation Information\\{8EE5A3C1-50E3-4ED3-9341-2B6814536041}\\Setup.exe";
LaunchAppAndWait(svValue2, "/removeonly /SMS", LAAW_OPTION_WAIT);
MessageBox("After LaunchAppAndWait",INFORMATION);


Basically, I'm extracting the Setup.exe and passing arguments /removeonly and /SMS to force unistall of previous version and wait for Setup.exe to complete.

This resolves the problem of the Wait (it makes the LaunchAppAndWait wait for Setup.exe to complete) as I wanted,... but now I faced a different problem:

During uninstall of previous version, I get the "Files In Use" dialog box informing that some files that need to be updated are currently in use. The text displayed in the files in use box is:
"1: ProductSetup 2: xxxx" (note that xxxx is the product I want to Install)
I understand by this that 2 instances of the msiexec.exe are being used.


Then, I tried another method: I removed the above code and decided to create a MajorUpgrade to make sure the previous version is uninstalled before the new one gets installed.
It happened the same!!! during previous version uninstall, it showed the "Files in use" dialog box with the same message as above....

Does anyone know what can be the problem? how am I supposed to make sure that I uninstall completely the previous version of my product before the installation of the new version continues?

The funny thing is that with the very first code sample (where uninstallapplication fails to wait for uninstall to complete), the uninstallation of previous version completes successfully with no files in use message, so I could trust user will always behave well and say yes to uninstall before he says yes to start the new installation... but I would prefer to avoid that.

Thanks,
Oscar
Labels (1)
0 Kudos
(1) Reply
_Oscar_
Level 3

I think I found a possible workaround to my problems:

- The reason of the problem seems to be the option "-runfromtemp" in the UninstallString of my application when installed.

If I edit the registry and remove this option manually, then the newer version install waits until the previous version uninstall completes fine.
The workaround I'm using at the moment consists of removing the -runfromtemp from the UninstallString before using it.

I paste the workaround used for anybody who can reuse it.


nTmp = RegDBKeyExist( "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall" ^ "InstallShield_" + svValue );
if( nTmp == 1 ) then

nvType = REGDB_STRING;
svFullUninstallString="";
nvSize=-1;
szKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall" ^ "InstallShield_" + svValue;
RegDBGetKeyValueEx( szKey, "UninstallString", nvType, svFullUninstallString, nvSize );
//e.g. of UninstallString
//"C:\Program Files\InstallShield Installation Information\{B9A7C16F-80EC-41CB-9A8B-41E4C4BB305D}\productsetup.exe" -runfromtemp -l0x0409 -removeonly
StrToLower(svTempString,svFullUninstallString);

//Extract the full path for ProductSetup
nLocation = -1;
nLocation = StrFind(svTempString,"-runfromtemp");
if (nLocation > 0) then
StrSub(svTempString,svFullUninstallString,0,nLocation+StrLength("-runfromtemp"));
StrSub(svTempString2,svFullUninstallString,nLocation+StrLength("-runfromtemp")+1,StrLength(svFullUninstallString));
svTempString = svTempString + svTempString2;
LaunchAppAndWait("", svTempString, LAAW_OPTION_WAIT);
else
LaunchAppAndWait("", svFullUninstallString, LAAW_OPTION_WAIT);
endif;

else
nReturn = UninstallApplication ( svValue, "", LAAW_OPTION_WAIT|LAAW_OPTION_SET_BATCH_INSTALL );
endif;


But, why is this "-runfromtemp" set in the UninstallString by default ? ( I haven't done anything in my MSI Installscript project to add it )

Does anybody know how to avoid that a MSI Installscript project sets this "-runfromtemp" in the UNINSTALL_STRING ?

Is there any other way to remove this tag a part from modifying the UNINSTALL_STRING during install time?
0 Kudos