简体   繁体   中英

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

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?

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)

In case anyone else ever faces the issue:

you can start most windows apps in cmd with the following syntax:

start [program]:

ex:

start Netflix:

Keeping this in mind, to port to pythn simply use the following code:

import os
os.system('start Netflix:')

replace with your program of choice and voila :)

You can use this new technique, its called winapps its used for searching, modifying, and uninstalling apps. Its download command on cmd windows is pip install winapps .

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

Welcome to 2022!

You can simply make use of PYPI module AppOpener .

# pip install AppOpener
from AppOpener import run
run("word") #Opens word
run("excel, notepad") # Opens excel & notepad

Visit AppOpener's documentation here .

Not only windows apps, you can also open any application installed in your system

# pip install AppOpener
from AppOpener import run
run("whatsapp") #Opens whatsapp if installed
run("whatsapp, telegram") # Opens whatsapp & telegram

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM