12

我需要一种从命令行在 Metro 应用程序中打开文件的方法。

到目前为止,我已经弄清楚如何在没有任何第三方脚本的情况下从命令行启动应用程序

explorer shell:AppsFolder\Microsoft.Reader_8wekyb3d8bbwe!Microsoft.Reader

但我还没有弄清楚如何包含文件名。

发射

explorer shell:AppsFolder\Microsoft.Reader_8wekyb3d8bbwe!Microsoft.Reader example.pdf

只是打开一个默认的资源管理器窗口。

来自 Windows 8 专家的关于如何在没有任何第三方工具/cmdlet/等的情况下完成此操作的任何想法?

注意:事实上我使用的是 Windows 10,但我想如果有 Windows 8 / 8.1 的方式来做到这一点,它也适用于 10。

4

5 回答 5

8

If you're still looking for the answer, the best way to open a file in a metro app is to use an execution string like a normal app protocol does. The execution string looks like this:

bingnews:[arguments, can be left blank.]
microsoftvideo:[arguments, can be left blank.]
netflix:[arguments, can be left blank.]

So, to start up netflix, it's as simple as typing in Start netflix: into the command line.

To find the execution string for an app, go here: Control Panel\Programs\Default Programs\Set Associations


More info and examples can be found here.

http://windowsitpro.com/windows-8/opening-windows-8-apps-command-prompt-or-script

http://www.itsjustwhatever.com/2012/10/28/launch-windows-8-metro-apps-from-a-desktop-shortcut-or-command-line/


PLEASE NOTE: To open an app WITHOUT A PROTOCOL (One not listed in the registry or under "Set Associations") use OP's method:

explorer shell:AppsFolder\[appuid]![appfullname]

The app UID is the folder name without the version number. For example,

4DF9E0F8.Netflix_2.11.0.8_x64__mcm4njqhnhss8

becomes

4DF9E0F8.Netflix_mcm4njqhnhss8

The app fullname is the [App author].[App name] For example, 4DF9E0F8.Netflix. 4DF9E0F8 is the author, and Netflix is the name.

Put it all together to get

explorer shell:AppsFolder\4DF9E0F8.Netflix_mcm4njqhnhss8!4DF9E0F8.Netflix

于 2015-04-08T23:37:30.520 回答
4

商店应用程序只能由 shell 启动。所以试试这个:

explorer.exe shell:AppsFolder\Microsoft.WindowsAlarms_8wekyb3d8bbwe!App

或从运行(Win+R):

shell:AppsFolder\Microsoft.WindowsAlarms_8wekyb3d8bbwe!App
于 2016-09-14T12:15:41.323 回答
2

If the app is the default handler then you can just launch the file or protocol. There isn't a good in-box way to launch a file into a non-default handler from the command line.

Windows Store apps aren't designed to run from the command line and there isn't a straightforward way to launch them from the command line. Apps which handle specific files or protocols receive them through FileActivatedEventArgs or ProtocolActivatedEventArgs rather than command line arguments

You could write a launcher app which uses CLSID_ApplicationActivationManager's IApplicationActivationManager to ActivateForFile a specific app.

于 2014-10-09T22:11:35.447 回答
1

不确定它是否适用于 Windows 8,但在 Windows 10 上我使用这个:

cmd /C start <app-name>:

例如,要启动 Slack:

cmd /C start slack:
于 2017-11-16T16:53:46.230 回答
1

我发现将命令行参数传递给 shell 命令所针对的可执行文件的最佳方法是通过 Windows 启动命令。

使用您的示例,您将得到以下结果:

start "" shell:AppsFolder\Microsoft.Reader_8wekyb3d8bbwe!Microsoft.Reader example.pdf

我没有安装 Microsoft.Reader,所以无法测试。但是,我可以验证此模式是否适用于 Windows 终端。在这种情况下,我向它传递了一个命令行参数来告诉它我要打开哪个配置文件。

start "" shell:AppsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App new-tab -p "GitBash"

这里 start 命令的第一个参数——空字符串——只是窗口的标题。

您也可以将它与 配对cmd /c,我发现它对于某些启动器应用程序是必需的,例如我个人最喜欢的 SlickRun:

cmd /c start "" shell:AppsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App new-tab -p "GitBash"

我有一篇博客文章,其中包含有关从命令行运行现代应用程序的更多信息,您可能会发现它有助于构建这些荒谬的钝命令。

于 2021-07-27T13:38:45.863 回答