Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening a file in a Metro app from command line

I need a way to open a file in a Metro app from command line.

So far I've figured out how to start the app from command line without any third-party scripts

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

but I haven't been able to figure out how to include a file name yet.

Launching

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

just opens up a default explorer window.

Any idea from Windows 8 experts on how to accomplish this without any third-party tools/cmdlets/etc.?

Note: In fact I'm using Windows 10 but I guess if there's a Windows 8 / 8.1 way to do it, it'll work for 10, too.

like image 927
Sora. Avatar asked Oct 07 '14 20:10

Sora.


1 Answers

The best way I've found to pass command-line arguments to the executable targeted by the shell command is via the Windows start command.

Using your example, you would end up with this:

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

I don't have Microsoft.Reader installed, so I can't test that. However, I can verify that this pattern works with Windows Terminal. In this case, I pass it a command-line argument to tell it which profile I want to open.

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

The first argument to the start command here — the empty string — is just the title of the window.

You can also pair this with cmd /c, which I've found is necessary for some launcher applications, such as my personal favorite, SlickRun:

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

I have a blog post with more info on running Modern apps from the command line, which you might find helpful in constructing these ridiculously obtuse commands.

like image 93
Mark McClelland Avatar answered Oct 13 '22 09:10

Mark McClelland