IRMEK / run_custom_app.py
SimpleSam's picture
Update run_custom_app.py
036cb0c verified
Raw
History Blame Contribute Delete
1.28 kB
import subprocess
import os
def open_application(custom_app_name):
"""
Opens common Windows applications based on a user-friendly name.
"""
# Dictionary mapping friendly names to Windows execution commands
apps = {
chrome_path: r"C:\Program Files\Google\Chrome\Application\chrome.exe"
"word": "winword",
"powerpoint": "powerpnt",
"excel": "excel",
"notepad": "notepad",
"calculator": "calc",
"browser": "start msedge" # Opens Microsoft Edge
}
# Normalize the input name
target = custom_app_name.lower().strip()
if target in apps:
print(f"Opening {custom_app_name.capitalize()}...")
try:
# shell=True allows running system aliases like 'winword' or 'calc'
subprocess.Popen(apps[target], shell=True)
print("✅ Application launched successfully.")
except Exception as e:
print("❌ The file path is incorrect. Please verify where the app is installed.")
else:
print(f"❌ '{custom_app_name}' is not in the configured list.")
# Example Usage
if __name__ == "__main__":
# Change this to "powerpoint", "excel", "notepad", or "calculator"
app_to_open = "word"
open_application(app_to_open)