| import subprocess |
| import os |
|
|
| def open_application(custom_app_name): |
| """ |
| Opens common Windows applications based on a user-friendly name. |
| """ |
| |
| 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" |
| } |
|
|
| |
| target = custom_app_name.lower().strip() |
|
|
| if target in apps: |
| print(f"Opening {custom_app_name.capitalize()}...") |
| try: |
| |
| 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.") |
|
|
| |
| if __name__ == "__main__": |
| |
| app_to_open = "word" |
| |
| open_application(app_to_open) |
|
|