How can I open a Windows 10 app with a python script?

10,896

Solution 1

import os
os.system('start D:\\bharat\\sqldeveloper.exe') 

For Windows cmd this [start path/app.exe] will open the app so just use the full path of the exe of required file (make sure to use \\ in path while writing python script)

Solution 2

Finally, I found a way to run Windows Universal apps which downloaded via Windows Store or preinstalled. Each Windows 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
OneNote for Windows 10    Microsoft.Office.OneNote_8wekyb3d8bbwe!microsoft.onenoteim
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
Feedback Hub              Microsoft.WindowsFeedbackHub_8wekyb3d8bbwe!App
Xbox Game Bar             Microsoft.XboxGamingOverlay_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

Now it's the time to back to Python:

>>> import os
>>> os.system('start explorer shell:appsfolder\Microsoft.BingWeather_8wekyb3d8bbwe!App')

The Windows Weather App will execute.

Happy Coding

Share:
10,896
Klaus Mana
Author by

Klaus Mana

Updated on June 04, 2022

Comments

  • Klaus Mana
    Klaus Mana almost 2 years

    So, as you may know there are certain apps on Windows that can be installed from the app store, and are classified as Windows Trusted Apps. I am not sure, but I think these do not use the classic .exe format. So I am writing a python script to automate some stuff when I start my pc, and I need to start a certain Windows App, but I don't know how to do this as I don't know what I need to start to do so, and I also do not know where these files are located. Anyone can help?

    • Eryk Sun
      Eryk Sun almost 7 years
      Is it enough to manually create a shell shortcut out of the virtual shell:appsfolder and have your script run it via os.startfile? Or do you need to fully automate finding the app's IDList in order to shell execute it?
    • Klaus Mana
      Klaus Mana almost 7 years
      @eryksun the issue I am having is that I totally do not know where the file is actually located...
    • Eryk Sun
      Eryk Sun almost 7 years
      You're not supposed to reference these apps by the executable. Eventually there is one of one sort or another -- typically in a subdirectory of the hidden system folder %ProgramFiles%\WindowsApps. Some apps support a URL protocol, like bingnews:, that you can use in Explorer or cmd's start. Otherwise you need the application user model ID (AUMID) for use with the IApplicationActivationManager COM interface. If you create a shortcut (i.e. a .lnk file) on your desktop from one of the apps in shell:appsfolder it contains the AUMID, and you can use os.startfile to run the shortcut.
    • Klaus Mana
      Klaus Mana almost 7 years
      @eryksun thanks for the reply and explanation!
  • btc4cash
    btc4cash almost 6 years
    This is not working. Windows 10 app cannot be ran from cmd like this. I tried with Instagram.
  • Casey
    Casey over 4 years
    The command start D:\\bharat\\sqldeveloper.exe doesn't work on Win10 CLI, only Powershell, and even with that, you have to run start first, then D:\\bharat\\sqldeveloper.exe. Another issue is os.system() is not the recommended way to do this. The better option is subprocess.call() to spawn a new process. Lastly, in Python3, the double-slashes are not required when a real string is prefaced with r, as in r'D:\bharat\sqldeveloper.exe'. This keeps syntax as close to bash as possible, so no need to escape the forward slash.
  • Praveen
    Praveen over 3 years
    this does not work with some apps like camera, photos etc
  • Hacker
    Hacker over 2 years
    This is crazy good.