views:

279

answers:

4

I'm planning to build a download manager application and would like to be able to launch the application when a user clicks a button the site. The application would obviously already need to be installed on the client machine.

There are a few reasons why this needs to be written using Silverlight, but they're not really relevant to the question. I only mention it so that people don't suggest that I use another technology.

A: 

Yes. Here is an example: http://www.silverlight.net/content/samples/apps/facebookclient/sfcquickinstall.aspx

Michael S. Scherotter
@Michael - Thanks for answering. The solution is not quite what I'm looking for. It only shows You have already installed this application, please launch it from your shortcut. To uninstall/reinstall please right click here and choose "Remove this application...". What I would like to do is for the OOB application to start when the user clicks on a button on the web page or in the in application running in browser..
marcnicol
That is because you've already installed the app.You can create a SL app that when in-browser just shows an install button but when it is running OOB, it shows the full UI.
Michael S. Scherotter
I want to launch an application that has already been installed.
marcnicol
+2  A: 

Hi, I think that is not possible according to this post post 1 and to other post. But I don't know if MS will change that in the last version of SL 4

Sebastian
A: 

Doing a bit of a mash up from two other posts [1] and [2].

But of course this will only work for Windows not Mac. There you will have to fallback to the @michael-s-scherotter style solution.

private void Button_Click(object sender, RoutedEventArgs e)
{
    if (Application.Current.HasElevatedPermissions && System.Windows.Interop.ComAutomationFactory.IsAvailable)
    {

        string run = "\""%ProgramFiles%\\Microsoft Silverlight\\sllauncher.exe"\" /emulate:"Silverface.xap" /origin:\"http://www.silverlight.net/content/samples/apps/facebookclient/ClientBin/Silverface.xap\" /overwrite";
        dynamic cmd = ComAutomationFactory.CreateObject("WScript.Shell");
        cmd.Run(run, 1, true);

    }
}
JProgrammer
A: 

I'm confused.

I thought elevated permissions only work in OOB.

Which means you can't launch a Silverlight OOB application from the browser except the first time when you install it.

Please correct me if I'm wrong.

schup