vulgrin
Posts: 40
Joined: Fri Jan 11, 2008 9:49 pm

Removing other MSIs

Apologies if this has been answered before, but I cannot search the forums for the answer because all of my words are getting marked as common words. (trying to search for a combo of "uninstall other MSI")

Anyway, I am customizing the uninstall to ask the user if they want to remove a related component. I followed the pattern in the How-To article for how to do this and it works fine, and the uninstallers launch at the end of my uninstaller.

The problem is, these uninstalls are launching after my product has been removed, but before the user has a chance to click the "Finished" button on the last pane of the dialogs. This causes the error where two MSIs are trying to uninstall at the same time, and messes up the flow.

Also, I need to be able to remove TWO MSI's after the user is done uninstalling the main product. Is this even possible, since my main installer will have been shut down already to uninstall the 2nd MSI? (And I have no control over the 2nd MSI's installer - its for a Microsoft product.)

Thanks
Dave
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Removing other MSIs

Hi Dave,
these uninstalls are launching after my product has been removed, but before the user has a chance to click the "Finished" button on the last pane of the dialogs.
Please note that the custom action which launches the uninstall should be set with the "Asynchronous execution, do not wait for return" option. Also, this approach supports only one MSI installation package. If you launch more than one MSI, the packages will run at the same time (this is not supported by Windows Installer).

A solution for this would be to use a custom action which launches each MSI and waits for it to finish before launching the next one.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
vulgrin
Posts: 40
Joined: Fri Jan 11, 2008 9:49 pm

Re: Removing other MSIs

AH - thats probably it, my installer is finishing but then TWO installers are launching.

Is there sample code already to do what you are talking about for launching each installer in turn - or is it just basically shell commands from VBS to run the command line? And does that VBS then run outside the scope of my initial MSI so that it won't conflict?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Removing other MSIs

Hi,
Is there sample code already to do what you are talking about for launching each installer in turn
Please note that you can use a simple BAT file which launches the MSI files with MSIEXEC. This BAT can be scheduled as a "Launch file or open URL" custom action under "InstallFinalize".

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
vulgrin
Posts: 40
Joined: Fri Jan 11, 2008 9:49 pm

Re: Removing other MSIs

Well, I ended up writing a VBS anyway, because there are some other files I need to clean up. But, it's still not working - the VBS is running fine, but it is getting launched during the uninstall and not waiting until the main uninstall is finished. It's trying to run the VBS during the progress dialog.

I have my custom action set up like this:

It's in the InstallFinalize sequence.
Source path points to my VBS
Source Type: *.vbs
Function Name: filled in and maps. (like I said, the VBS runs fine)
Execution properties: Asynchronous execution, do not wait for return
Execution Options: Immediate execution. (all other choices are greyed out.)
Scheduling Options: Always Execute
Execution Condition: Remove="ALL" and UNINSTALL_SQL=1 (the latter is set during the uninstall dialogs by the user.)

Any ideas?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Removing other MSIs

Hi,

I'm not sure why you are encountering this behavior. Can you please send us the AIP and a log of the installation to support at advancedinstaller dot com so we can investigate the problem?

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
vulgrin
Posts: 40
Joined: Fri Jan 11, 2008 9:49 pm

Re: Removing other MSIs

Sure - I'm trying one more thing, but can you tell me where the log is?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Removing other MSIs

Hi,

You can create a log of the uninstall process by running this command line:

Code: Select all

msiexec /x GUID /L*V "C:\package.log"
where you replace GUID with the Product Code of the MSI package.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
vulgrin
Posts: 40
Joined: Fri Jan 11, 2008 9:49 pm

Re: Removing other MSIs

The problem with that command line is that it doesn't allow me to step through the uninstall screens so that my UNINSTALL_SQL property that runs my VBS doesn't get set.

I'll remove that requirement and try it again.
vulgrin
Posts: 40
Joined: Fri Jan 11, 2008 9:49 pm

Re: Removing other MSIs

Files have been sent in. Let me know if you see anything unusual.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Removing other MSIs

Hi,

It seems that the VBScript you are using does not wait for MSIEXEC to finish. Therefore, the two uninstall processes are launched at the same time (the uninstall of your package was finished). Please note that this behavior does not occur when using a BAT file. This is because the BAT will wait for an uninstall to finish before launching the second one.

The best solution would be to use a BAT for uninstalling the MSIs and a VBScript for removing the rest of the files. Please note that BAT files can be run only with "Launch file or open URL" custom actions.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
vulgrin
Posts: 40
Joined: Fri Jan 11, 2008 9:49 pm

Re: Removing other MSIs

OKAY - I finally have it. For posterity and for others trying to do this, I'll log it here.

My uninstaller dialog asks the user if they want to remove SQL server express, if its installed. To achieve this I:
1. Wrote a bat file to remove SQL server, the SQL server tools, and the SQL Helper packages, and then delete itself. Here's the code:

Code: Select all

msiexec.exe /x "{2AFFFDD7-ED85-4A90-8C52-5DA9EBDC9B8F}" /qb
msiexec.exe /x "{2750B389-A2D2-4953-99CA-27C1F2A8E6FD}" /qb
msiexec.exe /x "{53F5C3EE-05ED-4830-994B-50B2F0D50FCE}" /qb
del removesql.bat
Note that you should look up and verify the product codes above - they might have changed for your version of SQL.

2. I include this file on the install. I put it into the System folder, so that I'm sure it stays around and stays semi-hidden.
3. Under Organization / Components, I've set this BAT file to be permanent. This way, it doesn't go away during the uninstall, which is very important.
4. During uninstall, I added a checkbox that the user has to check to tell me they want to remove SQL. (UNINSTALL_SQL)
5. I added a custom action to the InstallFinalize action, a "New Installed Custom Action" that maps to my BAT file in the system folder, and which has the Execution Properties set to "Asynchronous Execution, do not wait for return" and has an execution condition of: REMOVE="ALL" and UNINSTALL_SQL=1

If your app creates a new database on SQL Server, you might also need to remove your database files with another custom action via VBS. Here's mine.

Code: Select all

function removeSQL()
dim pathToFolder, root, subfolder, dbpath, logpath, objFS

Set objFS = CreateObject("Scripting.FileSystemObject")
pathToFolder = Session.Property("ProgramFilesFolder")
pathToFolder = pathToFolder + "Microsoft SQL Server"

if objFS.FolderExists(pathToFolder) then
set root = objFS.GetFolder(pathToFolder)

for each subfolder in root.Subfolders
dbpath = subfolder.Path + "/MSSQL/DATA/YOURDB.mdf"
logpath = subfolder.Path + "/MSSQL/DATA/YOURDB_log.ldf"
if objFs.FileExists(dbpath) = True then objFs.DeleteFile dbpath, True
if objFs.FileExists(logpath) = True then objFs.DeleteFile logpath, True
Next
end if

end function
Hope that helps someone else.

Return to “Common Problems”