I am trying to write a powershell script for windows 10 that will automatically launch a Metro-style app. The Start-Process cmdlet seems like it should work, but I cannot get it to launch anything unless I provide a path to the .exe
For example, the following input works:
Start-Process 'C:\Program Files\Internet Explorer\iexplore.exe'
Unfortunately, Metro style apps do not have an executable file. What file do I need to use to launch them? If I wanted to launch Windows Store for example, how would I do that?
Thanks
I don't know of a truly universal way to do this, but you can probably figure it out with a couple intermediary checks.
note: I hate using PowerShell, so pardon the weirdness of calling PS stuff from CMD
Step 1: Figure out what apps you have.
powershell Get-AppXPackage
will generate the list of all of them. Let's say you specifically want to launch the Desktop App Converter so you can handle some Centennial patching while leveraging automation. So I'll query against the list of AppXs for something that might match usingfindstr
to filter what comes back.Step 2: Figure out if you already have the app you want
powershell Get-AppXPackage | findstr /i Desktop
While that gives me back numerous results, I can clearly see set of matches returned as:
If I didn't get anythign like this back, the natural next step is to get the darned thing :) So for the next step, this could get tricky, and your mileage may vary:
Step 3: Find the location the app exists where you can actually call it: Why am I doing this? Because if I try to run it from the path returned from the AppXPackage query, I'll get
"Access is denied."
You should then be able to take that resulting path and be able to run it from there.
Store Apps can only be started by the shell. Try this:
You can locate the command to use with Start-Process by navigating here in the registry: Computer\HKEY_CLASSES_ROOT\Extensions\ContractId\Windows.Protocol\PackageId
Then expand ActivatableClassId, then the app, then in the CustomProperties folder look at the value for Name.
Start-Process must be run with PowerShell as is not recognised in CMD.
I used this to start the Windows Mail app.
You have to provide the name of the appx. For example, to launch windows store in Win8/Win10, use the following code:
I was amazed at how little documentation there is for launching metro style apps.
If you download the Windows SDK, there is an executable in there called:
microsoft.windows.softwarelogo.appxlauncher.exe
which can be used to launch UWP apps.The format is:
microsoft.windows.softwarelogo.appxlauncher.exe <packageFamilyName>!App
You can get the packageFamilyName of your app by looking at kayleeFrye_OnDeck's answer.