Answered How to Start a external Program from Metro App

  • Thursday, January 26, 2012 8:18 AM
     
     
    Is there a possibility to an external program from a metro app launch?
    Unfortunately I could not find the Process class in the namespace System.Diagnastic, the class is in another assembly, or is this not implemented?
    A Windows Forms test application developed in Visual Studio 2010 installed and works on Windows 8.

All Replies

  • Thursday, January 26, 2012 12:56 PM
     
     

    All the Metro-style applications work in the highly sandboxed environment and there is no way to directly start an external application.

    You can try to use Launcher class – depends on your need it may provide you a feasible solution.


     

  • Thursday, January 26, 2012 6:39 PM
     
     Answered
    Many thanks for the quick reply.
    I've found a solution and although I've had created its own file extension and backs them up my application.
    Then I created a new file with the file extension and the creation deposited in my project. Then I call the launcher with the stored file name and you will open the application. Very important that you are under the file properties, the "Build Action" to "content" and makes a local copy to "Copy Always" otherwise the file is not placed in the output directory.
    I also write my parameter values ​​in my file and I read this in turn made ​​in my Windows Forms application.
    Is a little cumbersome but it works, maybe, the team of Mirosoft again some time and extends the static class of the "Launcher" to a method "StartApplication()". It would be nice for the future:)
  • Tuesday, January 31, 2012 6:32 PM
    Moderator
     
     

    Hi Christian - we're moving away from allowing an application to start any other application.  You've found the best method of starting another process and that's to use the File Asssociations.  We're also encouraging the use of the Sharing Contract between apps that have different uses.

     


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
  • Thursday, July 05, 2012 8:39 AM
     
     Proposed Answer
    Is it possible to launch the batch file in metro style app with the above mechanism. Please reply.
    • Proposed As Answer by mdahling Saturday, January 12, 2013 7:01 PM
    •  
  • Monday, July 16, 2012 12:22 PM
     
     

    Matt please tell me one thing, does it actually work? I have been fiddling with this code from the example in the official documentation found here: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh701484.aspx#Y923 for weeks on and off.

    Here is the code:

    // The URI to launch
    string uriToLaunch = @"http://www.bing.com";
    var uri = new Uri(uriToLaunch);

    async void DefaultLaunch()
    {
       // Set the option to show a warning
       var options = new Windows.System.LauncherOptions();
       options.TreatAsUntrusted = true;

       // Launch the URI with a warning prompt
       var success = await Windows.System.Launcher.LaunchUriAsync(uri, options);

       if (success)
       {
          // URI launched
       }
       else
       {
          // URI launch failed
       }
    }

    I fails 100% i mean it does run but success is always false. Has it actaully been tested and works? Or is it  a case of saying it's here but untested?


    mathias


  • Monday, July 16, 2012 5:38 PM
     
     

    making a proxy native application is the best way I could think of.

    The trick here is simple and basic
    1. Metro create a text file with some sort of command
    2. Proxy monitors the file changes
    3. Once changed, proxy reads that file and process it
    4. Then proxy executes the file needed to run.

    check here for more information and code sample
    http://ss.jaysonragasa.net/?zt3qu

  • Tuesday, July 17, 2012 8:36 AM
     
     

    Jason thanks for the proof of concept. Like you rightly pointed out, one would have consider the
    cost of having to use a third party app just to run an application.

    I don't understand why MS would purpot that it is achievable through the protocal
    handlers when in-fact they haven’t bothered to test that it works, when in fact
    it doesn’t work!

    It is totally annoying, misleading, timewastsing, unhelpful to say the least.



    mathias


  • Thursday, August 09, 2012 4:27 PM
     
     

    So I am trying this approach too, I need to launch a WinForms app from a metro app.

    I followed the same steps. I have a custom file association, and the file with that extension in my package as content. I load it and call launcher to launch it, but it doesnt.

    If I call the launch from a button click, the winforms app DOES launch, but not when I call it from the NavigatedTo event of the app.

    Does Launcher.Launch have to be called in response to a user input event?

    John