Uninstall out-of-browser silverlight application programmatically

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-01 03:14:23

问题


How to uninstall out-of-browser silverlight 4 application programmatically instead of using the contextmenu (e.g. if I want to replace the context menu)?

Edit

I have found in "Installing Silverlight applications without the browser involved" how to uninstall by calling the command-line:

"%ProgramFiles%\Microsoft Silverlight\sllauncher.exe" /uninstall /origin:silverlight.net/content/samples/apps/…

This can be used in:-

 dynamic cmd = AutomationFactory.CreateObject("WScript.Shell");
 cmd.Run(run, 1, true);

Is there any better solution?


回答1:


Pretty certain this isn't possible without resorting to COM interop as Mike says, also I'd question if it's a good idea since:

1) Removing the uninstall option will no doubt annoy many users and is bad practice. 2) You say you are looking to implement a new context menu? Unless this is a LOB application I'd be wary of this as many users won't be used to accessing context menus in a web app which to me is poor HCI. If it is a LOB application then Add/remove programs would be an OK solution?




回答2:


I'm not sure you can do this programmatically.

One option is to get the user to use Add/Remove programs to remove it.

Another is to use the silent installation option to remove it ( link - http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2010/03/24/silverlight-4-rc-and-the-silent-installation.aspx ) but that involves COM interop calls.

Mike.




回答3:


The solution you mentioned is still the only way I know to do it. It's a nice touch put a Application.Current.MainWindow.Close(); after it though as the application will still be running after you do the uninstall.

Marc




回答4:


This isn't an answer, but it's related to your issue. On the official Silverlight wishlist, I added the ability to do this quite some time ago. Luckily, quite few users agree. With enough votes, hopefully it will appear in a future version of Silverlight.

http://dotnet.uservoice.com/forums/4325-silverlight-feature-suggestions/suggestions/410706-greater-control-over-installation-in-oob




回答5:


Check out my solution here: Unable to Uninstall SIlverlight Out Of Browser Application Programatically I used the code in it in console app that was run by the silverlight application that it was uninstalling. Silverlight extracted the EXE as a resource to one of the directories and then ran it using something like the following:

using (dynamic shell = AutomationFactory.CreateObject("WScript.Shell"))
{
     shell.Run(@"C:\Users\yourusername\AppData\update.exe xapNameToUninstall");
}


来源:https://stackoverflow.com/questions/2735621/uninstall-out-of-browser-silverlight-application-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!