Launching a Windows 10 Store app from C# executable

走远了吗. 提交于 2020-01-07 05:23:09

问题


So here's the gist of my problem: I have a keyboard where I can assign macros and/or launch programs from. I want to include a couple Win10 and Steam applications in that list. So I opted to build an executable "launcher", so to speak.

The code is simplistic in nature. I got Steam url's to work by placing the steam url into Process.Start("steam://rungameid/#####"). I cannot, however, figure out how to get Win10 apps to work. Here's my class:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        Process.Start(@"explorer.exe shell:AppsFolder\4DF9E0F8.Netflix_mcm4njqhnhss8!Netflix.App");
        Process.Start(@"shell:AppsFolder\4DF9E0F8.Netflix_mcm4njqhnhss8!Netflix.App");
        Process.Start("netflix://");

        Application.Exit();
    }
}

Each line of Process.Start() is what I've tried, to no avail.

The bottom line I attempted from this answer, which also did not work

The first line, I can put that in a Run box or from the command line saDand it will launch Netflix, but from the C# application, I get a "System cannot find the file" exception.

Thanks for any direction!


回答1:


Can you please check if you have installed this app and name you enter in the Process.Start(“ ”) is correct, You can find the names when you open the registry key HKEY_CLASSES_ROOT\Extensions\ContractId\Windows.Protocol\PackageId. Look for the CustomProperties key. It has an attribute Name. I use the below sample to open my photos, It works fine.

 private void Form4_Load(object sender, EventArgs e)
    {
        button2_Click(null,null);
    }
    private void button2_Click(object sender, EventArgs e)
    {
        Process.Start("ms-photos://");
    }


来源:https://stackoverflow.com/questions/42521332/launching-a-windows-10-store-app-from-c-sharp-executable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!