Every once in a while there comes a need to provide a mechanism to uninstall your application programmatically. For Silverlight Out-Of-Browser applications , there seemed to be no way to accomplish it. Fortunately, there’s a work-around that trusted OOB applications running in Windows can use.
Silverlight OOB applications are launched via the “sllauncher.exe” command. And if you open the properties on an OOB shortcut, you will see a target textbox with something like:
“C:Program Files (x86)Microsoft Silverlightsllauncher.exe” 2205248641.localhost
Of course, “sllauncher.exe” has some command-line parameters and settings we can use to install and uninstall Silverlight OOB applications. Since trusted Silverlight OOB applications can access COM Automation, we can run the “sllauncher.exe” application from within Silverlight. The catch is that we’re not sure exactly where the program is located.
There may be exceptions, but as a general rule “sllauncher.exe” is located in 1 of 2 places:
on 64-bit machines : C:Program Files (x86)Microsoft Silverlightsllauncher.exe
on 32-bit machines : C:Program FilesMicrosoft Silverlightsllauncher.exe
However, there’s no way to know which OS type you’re running on. So we need to check for the existence of these folders. Since they’re out of the sandbox, we have to resort to COM Automation to determine if they exist.
1: string launcherPath = string.Empty;
2: using (dynamic shell = AutomationFactory.CreateObject("Shell.Application"))
3: {
4: string launcher64 = @"C:Program Files (x86)Microsoft Silverlight";
5: string launcher32 = @"C:Program FilesMicrosoft Silverlight";
6:
7: dynamic folder64 = shell.NameSpace(launcher64);
8: if (folder64 != null) launcherPath = launcher64;
9:
10: dynamic folder32 = shell.NameSpace(launcher32);
11: if (folder32 != null) launcherPath = launcher32;
12: }
To silently uninstall a Silverlight OOB application using “sllauncher.exe” you’d normally type something like:
sllauncher.exe /uninstall /origin:[origin location]
Once again, using COM Automation, we can have our application run the command.
1: using (dynamic shell = AutomationFactory.CreateObject("WScript.Shell"))
2: {
3: string origin = Application.Current.Host.Source.OriginalString;
4: shell.Run(string.Format(@"{0}/sllauncher.exe /uninstall /origin:""{1}""", launcherPath, origin));
5: }
That’s really all there is to it (other than adding in some error checking, of course).
Microsoft Azure and Amazon Web Services (AWS) are two of the most popular cloud platforms.…
Cloud management is difficult to do manually, especially if you work with multiple cloud…
Azure’s scalable infrastructure is often cited as one of the primary reasons why it's the…
https://www.youtube.com/watch?v=wDzCN0d8SeA Watch our "Unlocking the Power of AI in your Software Development Life Cycle (SDLC)"…
FinOps is a strategic approach to managing cloud costs. It combines financial management best practices…
Using Kubernetes with Azure combines the power of Kubernetes container orchestration and the cloud capabilities…
View Comments
PingBack from http://www.silverlightshow.net/news/Programmatically-Uninstalling-Silverlight-Out-Of-Browser-Application.aspx