by Jason Han

如何使用C#调用Microsoft App Store 中下载的应用

Win10之后,许多之前常用的应用,包括录音机、照相机等,都被归为了 Microsoft App Store 所管理的范畴,无法直接通过诸如 Process.Start(“video.exe”)、Process.Start(“camera.exe”)等命令调用。目前较为可行的方法是,通过调用 cmd,再将自动填入命令,最终实现 App 的调用。示例代码如下:

Process p = new Process();
//设置要启动的应用程序
p.StartInfo.FileName = "cmd.exe";
//是否使用操作系统shell启动
p.StartInfo.UseShellExecute = false;
// 接受来自调用程序的输入信息
p.StartInfo.RedirectStandardInput = true;
//输出信息
p.StartInfo.RedirectStandardOutput = true;
// 输出错误
p.StartInfo.RedirectStandardError = true;
//不显示程序窗口
p.StartInfo.CreateNoWindow = true;
//启动程序
p.Start();
// shell 后面的link可能因app的版本而异
p.StandardInput.WriteLine(@"explorer.exe shell:AppsFolder\2568CaiJunhong.CompassOne_nnrr2ryxcqq94!App");
p.Close();

该示例调用的是“指北针”,其所对应的链接2568CaiJunhong.CompassOne_nnrr2ryxcqq94!App可通过如下方式获取1

  1. 先打开 cmd,输入explorer.exe shell:AppsFolder\,此时打开了应用文件夹,如图所示:

    image-20201230145443759

  2. 选中其中一个应用,右键创建快捷方式至桌面;

  3. 右击桌面的快捷方式,选择属性,即可获得上述链接,如图所示:

    image-20201230145616474

参考


  1. https://answers.microsoft.com/en-us/windows/forum/windows_10-windows_store/starting-windows-10-store-app-from-the-command/836354c5-b5af-4d6c-b414-80e40ed14675 ↩︎

This page and its contents are copyright © 2021, Jason Han.