20

I'm developing an automation system and one of it's features is running applications from the command line(I mean, automatically without human intervation).

On Windows 7 I could run everything I want from a command-line call, there is some similar way to do the same with Windows 8 with also the Metro-apps installed on it?

Sathyajith Bhat
  • 61,504
  • 38
  • 179
  • 264
Diogo
  • 30,192
  • 65
  • 150
  • 222

4 Answers4

12

Yeah! I found a way...

Based on this source code("Open a Metro Style App from Desktop App"), I realized that I could call the metro apps just as we usually run manually. I mean, if you press Ctrl + Esc and go to metro's screen, you could just type the name of the metro app, such as "store" for example, press Enter and that's it, the metro app is running. Based on this I created a very simple VBScript to do exactly these steps automatically:

Set objShell = WScript.CreateObject("WScript.Shell")

objShell.SendKeys "^{ESC}"

WScript.Sleep 1000

objShell.SendKeys WScript.Arguments.Item(0)

WScript.Sleep 1000

objShell.SendKeys "{ENTER}"

Save this as "metro.vbs" and call it from the command-line with the name of the metro app on first argument:

metro.vbs store

That is it, very simple and optimized way.

PS: All credits gave to AlKhuzaei, the Codeplex site user who created the related code. Thank you.

Diogo
  • 30,192
  • 65
  • 150
  • 222
  • Ah, I was wondering the same thing. Interesting solution. The only problem is if you have two programs with the same name, like both the Metro and desktop versions of Evernote installed. Which gets launched with the above?? There should be another way since Visual Studio can launch the application you are developing. – Jim McKeeth Jun 14 '12 at 18:27
  • I think that because the ctrl+esc, it will open only the metro app... It is something that would woth the test. – Diogo Jun 14 '12 at 18:30
  • Nope, just tried it. [Ctrl]+[Esc] is the same as [Win], and both just show the **Start Menu**, which is allows launching any program there - Metro and Desktop alike. – Jim McKeeth Jun 14 '12 at 18:32
  • So, what does Windows 8 does when two apps metro and desk have the same name??? It become duplicated on metro interface? – Diogo Jun 14 '12 at 18:33
  • Yeah, it is really annoying. I uninstalled the Metro version of Evernote for precisely that reason. – Jim McKeeth Jun 14 '12 at 19:18
  • Hmmm, you tried to execute the vbs command with it to see if it opens the desktop or metro? Maybe Windows will always open metro first than desktop on this specific script... (maybe :D) – Diogo Jun 14 '12 at 20:14
  • Clever solution. Would be interested to see if there ends up being a more direct method eventually, but this is a cool way to do it. – nhinkle Jun 19 '12 at 05:52
6

The following blog post and supporting code show you how to do this with IApplicationActivationManager in PowerShell.

Get a list of metro apps and launch them in Windows 8 using PowerShell « Tome's Land of IT

Fortunately, I was able to find some code on Stack Overflow that showed how to use this in C# (the post also listed the registry information I will describe in this article). After some tweaking the code and the Add-Type syntax, I was able to expose the function I needed into PowerShell. After that it was only a matter of wrapping the function into something that resembles PowerShell.

The code can be found on poshcode.

5

I just figured out another way to do it and wrote up a quick article on it at http://www.itsjustwhatever.com/2012/10/28/launch-windows-8-metro-apps-from-a-desktop-shortcut-or-command-line/

The short version: create a shortcut that points to bingnews:// You can see if it does what you want. If so there is more instruction to get the names on the website.

Nick
  • 51
  • 1
  • 1
1

I found a way to run Windows Universal apps which downloaded via Windows Store or preinstalled. Each Windows 8/10 Universal app has an AUMID which stands for 'Application User Model ID'.

PowerShell Command to get all AUMID:

get-StartApps

Output:

PS C:\> get-StartApps

Name                      AppID
----                      -----
Skype                     Microsoft.SkypeApp_kzf8qxf38zg5c!App
Snip & Sketch             Microsoft.ScreenSketch_8wekyb3d8bbwe!App
Mail                      microsoft.windowscommunicationsapps_8wekyb3d8bbwe!microsoft.w...
Calendar                  microsoft.windowscommunicationsapps_8wekyb3d8bbwe!microsoft.w...
Movies & TV               Microsoft.ZuneVideo_8wekyb3d8bbwe!Microsoft.ZuneVideo
Photos                    Microsoft.Windows.Photos_8wekyb3d8bbwe!App
Video Editor              Microsoft.Windows.Photos_8wekyb3d8bbwe!SecondaryEntry
Maps                      Microsoft.WindowsMaps_8wekyb3d8bbwe!App
Alarms & Clock            Microsoft.WindowsAlarms_8wekyb3d8bbwe!App
Voice Recorder            Microsoft.WindowsSoundRecorder_8wekyb3d8bbwe!App
Camera                    Microsoft.WindowsCamera_8wekyb3d8bbwe!App
Microsoft Store           Microsoft.WindowsStore_8wekyb3d8bbwe!App
Weather                   Microsoft.BingWeather_8wekyb3d8bbwe!App
Cortana                   Microsoft.549981C3F5F10_8wekyb3d8bbwe!App
Instagram                 Facebook.InstagramBeta_8xx8rvfyw5nnt!Instagram
...

So now, you can start any universal app via its AUMID like this:

explorer shell:appsfolder\[AUMID]

For example, if you want to execute Skype:

explorer shell:appsfolder\Microsoft.SkypeApp_kzf8qxf38zg5c!App