none
How to Start a external Program from Metro App

    Question

  • 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.

    Thursday, January 26, 2012 8:18 AM

Answers

  • 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:)
    Thursday, January 26, 2012 6:39 PM

All replies

  • 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 12:56 PM
  • 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:)
    Thursday, January 26, 2012 6:39 PM
  • 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
    Tuesday, January 31, 2012 6:32 PM
    Moderator
  • 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
    Thursday, July 05, 2012 8:39 AM
  • 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 12:22 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

    Monday, July 16, 2012 5:38 PM
  • 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


    Tuesday, July 17, 2012 8:36 AM
  • 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

    Thursday, August 09, 2012 4:27 PM
  • I needed to
    open a file from a network location in pdf reader.  This is the easiest
    way I found and it worked.<o:p></o:p>

    "Windows.System.Launcher.LaunchUriAsync(new
    Uri("
    </o:p">\\computer\File.ext"));"<o:p></o:p>

    from : http://social.msdn.microsoft.com/Forums/windowsapps/en-US/1baee9f8-d827-46c4-8d8f-488faf9def62/how-to-open-a-networkfile-location-from-metro-style-app-<o:p></o:p>

     <o:p></o:p>

    Other stuff
    I was trying (var file = await
    Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(loc);)
    was throwing error (FileNotFoundException : The system cannot find the file
    specified. (Exception from HRESULT: 0x80070002))trying to find content unless
    it was compiled in my app as content.<o:p></o:p>



    • Edited by Nack1 Friday, July 19, 2013 4:02 PM format
    Friday, July 19, 2013 4:02 PM