Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
404 views
in Technique[技术] by (71.8m points)

c# - How to start a Process from a Win 8 App?

I can’t find System.Diagnostics.Process to start a new process. I guess this is on purpose. But is there a other way? Is this even possible?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can use this reference on Windows 8 Metro application : How to Start a external Program from Metro App. All the Metro-style applications work in the highly sand boxed environment and there is no way to directly start an external application.

You can try using Launcher class

  1. Launcher.LaunchFileAsync

    // Path to the file in the app package to launch
    string exeFile = @"C:Program Files (x86)App.exe";
    
    var file = await Windows.ApplicationModel.Package.Current.InstalledLocation
                            .GetFileAsync(exeFile);
    
    if (file != null)
    {
        // Set the option to show the picker
        var options = new Windows.System.LauncherOptions();
        options.DisplayApplicationPicker = true;
    
        // Launch the retrieved file
        bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
        if (success)
        {
           // File launched
        }
        else
        {
           // File launching failed
        }
    }
    
  2. Launcher.LaunchUriAsync

Reference: Can I use Windows.System.Launcher.LauncherDefaultProgram(Uri) to invoke another metro style app?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...