如果你只是想运行像(记事本,写字板,IE浏览器等)的桌面应用程序然后再通过Process Methods和ProcessStartInfo Class
try
{
// Start the child process.
Process p = new Process();
// Redirect the output stream of the child process.
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = "C:\Path\To\App.exe";
p.Start();
}
//实验2
// Uses the ProcessStartInfo class to start new processes,
// both in a minimized mode.
void OpenWithStartInfo()
{
ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
Process.Start(startInfo);
startInfo.Arguments = "www.northwindtraders.com";
Process.Start(startInfo);
}
在Windows 8 Metro应用我发现了这一点:How to Start a external Program from Metro App。
所有的Metro风格的应用程序工作在高沙盒 环境中,并且没有办法直接启动外部应用程序 。
您可以尝试使用Launcher class - 取决于您的需要它可能为 提供了一个可行的解决方案。
检查:
Can I use Windows.System.Launcher.LauncherDefaultProgram(Uri) to invoke another metro style app?
编号:How to launch a Desktop app from within a Metro app?
地铁IE是一个特殊的应用程序。您不能从Metro风格的应用程序调用可执行文件。
试试这个 - 我还没有测试,但还可能会帮助你..
Launcher.LaunchFileAsync
// Path to the file in the app package to launch
string exeFile = @"C:\Program Files (x86)\Steam\steamapps\common\Skyrim\TESV.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 launch failed
}
}
由于沙箱,您无法启动桌面应用程序(或其他进程)。您可以做的最好做法是“启动”文件或URI,以便启动关联的默认程序(可能是桌面应用程序)。 – 2012-03-02 07:25:41
那我该怎么做? – JacobTheDev 2012-03-06 19:03:48
“启动”URI,你的意思是?你使用'Windows.System.Launcher'类,特别是'LaunchUriAsync'方法。它在下面的回复之一中给出。 – 2012-03-06 20:01:01