2012-11-26 28 views
4

我無法找到System.Diagnostics.Process來啓動新進程。我想這是故意的。但是還有其他方法嗎?這甚至有可能嗎?如何從Win 8應用程序啓動進程?

+0

請問http://stackoverflow.com/questions/12334226/open-an-url-in-the-default-web-browser-in-winrt有幫助嗎? –

+0

不......我不想打開URL/URI。 –

+0

@MarcelB無法直接從Win 8應用程序啓動EXE ... – Yahia

回答

4

您可以在Windows 8 Metro應用程序中使用此引用:How to Start a external Program from Metro App。 所有Metro風格的應用程序都工作在高度沙盒環境中,無法直接啓動外部應用程序。

您可以嘗試使用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

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

0

看起來無法打開任何非地鐵流程。您可以打開URL或文件,如* .txt,但不能* .cmd或* .exe。

如果有一個自定義文件關聯,您可能(我沒有嘗試過)通過打開一個帶有自定義文件擴展名的空文件來啓動一個進程。但是,您無法編輯註冊表以從您的應用添加關聯。
所以沒有應用程序的唯一方法來做到這一點(除了尚未發現的黑客;))。

+1

如果你想讓你的Windows商店應用程序通過認證,並真正進入Windows商店,那麼「黑客」不是一個選項。 –

+0

我知道......我不是那個認真的人...... –

相關問題