Click here to Skip to main content
Click here to Skip to main content

How to launch external application or file from Silverlight 4

, 7 Sep 2010
Rate this:
Please Sign up or sign in to vote.
Launching external application or file from Silverlight 4 (out-of-browser) using Automation Factory

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

kj-dev
Software Developer (Junior) freelancer
Poland Poland
No Biography provided

Comments and Discussions

 
GeneralMy vote of 1 Pinmembermtss9221-May-14 1:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140826.1 | Last Updated 7 Sep 2010
Article Copyright 2010 by kj-dev
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid