Thursday 15 March 2012

c# - Uninstall a application during installation not working -



c# - Uninstall a application during installation not working -

i developing wpf application in c#. msi install current application in machine.i need uninstall 2 supporting application of existing version during installation of new one(msi).

i written code uninstall application programmatically , not work when phone call application uninstallation method in installer.cs.the same method uninstall 2 application when phone call other part of project other installer.cs.

uninstallation method:

public static string getuninstallcommandfor(string productdisplayname) { registrykey localmachine = registry.localmachine; string productsroot = @"software\microsoft\windows\currentversion\installer\userdata\s-1-5-18\products"; registrykey products = localmachine.opensubkey(productsroot); string[] productfolders = products.getsubkeynames(); foreach (string p in productfolders) { registrykey installproperties = products.opensubkey(p + @"\installproperties"); if (installproperties != null) { string displayname = (string)installproperties.getvalue("displayname"); if ((displayname != null) && (displayname.contains(productdisplayname))) { string filename = "msiexec.exe"; string arguments = "/x{4f6c6bae-eddc-458b-a50f-8902df730ced}"; processstartinfo psi = new processstartinfo(filename, arguments) { createnowindow = true, useshellexecute = false, redirectstandardoutput = true }; process process = process.start(psi); process.waitforexit(); homecoming uninstallcommand; } } } homecoming ""; }

update:after using wix msi installer

i have created customaction project in wix, created setup project using wix.please see product.wxs

<installexecutesequence> <custom action='showcustomactioncustomaction' after='installfinalize'>not installed</custom> </installexecutesequence>

i have code uninstall 3 application in customaction.cs.when run wix msi,it install new application , uninstall first application.the remaining 2 application not uninstalled,i noticed after successful uninstall of first application ui closes , nil happens.

can tell me how uninstall 3 application during installation of wix msi.

update 2:

<property id="previousversionsinstalled" secure="yes" /> <upgrade id="89cf8be7-05ee-4c7e-9efc-0249dd260ebb"> <upgradeversion minimum="1.0.0.0" maximum="99.0.0.0" property="previousversionsinstalled" includeminimum="yes" includemaximum="no" /> </upgrade> <installexecutesequence> <removeexistingproducts before="installfinalize" /> </installexecutesequence> </product>

the above settings in product.wxs uninstalling previous version , install new one.along need uninstall 2 dependency application also.how uninstall dependency application using wix installer.

can 1 help me how check installed application in machine , uninstall before installation of new wix msi.

there mutex in msi prevents concurrent installation / uninstalls. has happen within context of single installer. said, way author rows upgrade table teach findrelatedproducts , removeexistingproducts remove additional installed msis.

you don't mention using create msi can't show how that.

you've mentioned using vdproj. tool doesn't back upwards authoring trying do. suggestion refactor using windows installer xml (wix) , author multiple upgrade elements remove various products.

c# visual-studio-2010 c#-4.0 wix

No comments:

Post a Comment