6

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?

AnthonyWJones
  • 187,081
  • 35
  • 232
  • 306
Alexander Zwitbaum
  • 4,776
  • 4
  • 48
  • 55
  • I have found in http://timheuer.com/blog/archive/2010/03/25/using-sllauncher-for-silent-install-silverlight-application.aspx how to uninstall by calling the command-line: "%ProgramFiles%\Microsoft Silverlight\sllauncher.exe" /uninstall /origin:http://www.silverlight.net/content/samples/apps/facebookclient/ClientBin/Silverface.xap This can be used in dynamic cmd = AutomationFactory.CreateObject("WScript.Shell"); cmd.Run(run, 1, true); Is any better solution available? – Alexander Zwitbaum Apr 29 '10 at 08:07
  • Please use the question edit feature to include additional info rather than a comment. – AnthonyWJones Apr 29 '10 at 09:44
  • 3
    I'm too wondering, how to do that on Mac? Gosh... even in fifth version of SL, some out of browser stuff looks so darn ugly. Why can't I call directly the app from the browser if it's already installed? Why can't I uninstall it (I mean in code)? Why CheckAndDownloadUpdateAsync() doesn't always work... – iLemming Dec 21 '11 at 21:15

5 Answers5

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.

Mike
  • 46
  • 1
1

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

marcnicol
  • 180
  • 1
  • 8
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?

Sidebp
  • 770
  • 1
  • 10
  • 26
  • You could also want to have a button to install, and another to uninstall (was my case). Replacing the right click menu was useful for me too, to put very advanced stuff, but losing the uninstall command forced me to forget about that solution. – jv42 Dec 22 '11 at 15:46
1

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

0

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");
}
Community
  • 1
  • 1
TChadwick
  • 868
  • 10
  • 19