Problem
I have been recently trying to automate the instalation of COM server for my Silverlight app and I found it pretty hard to find any solution. The thing is I wanted to run the downloaded setup file from Silverlight code, which turned out to be not so easy in Silverlight application.
Solution
Reading KunalChowdhury's article (File Explorer using Silverlight 4 COM Interoperability), I have noticed he pointed out it is possible using COM.
After quite annnoying search I have finally found SpoonStomper's post on Silverlight forum.
Original solution was for JavaScript using ActiveX but, as I have checked immediately, it works also with AutomationFactory in Silverlight 4.
private void Run(string path)
{
try
{
dynamic shell= AutomationFactory.CreateObject("WScript.shell");
shell.run(path);
}
catch (System.Exception)
{
MessageBox.Show("failure");
}
}
The Run method creates shell object and runs application or file with path given in param. It allows to launch any external application or open any file with program related to this file.
WScript reference can be found here.
This solution will work only in out-of-browser mode with elevated permisions.