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.
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.
That’s really all there is to it (other than adding in some error checking, of course).