Create a Desktop Shortcut for Python Scripts & Streamlit Apps
Introduction to Python Shortcuts
Launching a Python script or Streamlit app shouldn’t mean navigating folders or typing commands every time. A desktop shortcut for a Python script on Windows streamlines this process, making it fast and user-friendly. Whether it’s a standard script or a Streamlit project requiring a virtual environment, this guide shows you how to set up shortcuts that save time and effort.
From basic Python execution to automating Streamlit app launches, we’ve got you covered with clear, step-by-step instructions.
1. Standard Python Script Shortcut
Here’s how to create a basic Python script shortcut for any script.
Step 1: Locate Your Python Script
Find your script’s full path, e.g., C:\Users\YourName\Scripts\my_script.py
. Copy this for later use.
Step 2: Find Your Python Executable
Locate your Python installation by running where python
in Command Prompt. Example output: C:\Users\YourName\AppData\Local\Programs\Python\Python39\python.exe
.
Step 3: Create a Shortcut
- Right-click on the desktop → New → Shortcut.
- In the location field, enter:
"C:\path\to\python.exe" "C:\path\to\your_script.py"
. Example:"C:\Users\YourName\AppData\Local\Programs\Python\Python39\python.exe" "C:\Users\YourName\Scripts\my_script.py"
- Click Next, name it (e.g., “My Script”), and click Finish.
Step 4: Modify Shortcut Properties (Optional)
For a silent run (no console window), use pythonw.exe
instead: "C:\path\to\pythonw.exe" "C:\path\to\your_script.py"
.
2. Running a Streamlit App via a Shortcut
For Streamlit apps, you need to activate a virtual environment first. This shortcut automates that process.
Step 1: Identify Your Virtual Environment Path
Locate your activate.bat
file, e.g., F:\PYTHON\STREAMLIT\kinopoisk\.venv\Scripts\activate.bat
.
Step 2: Find Your Streamlit App Path
Find your app file, e.g., F:\PYTHON\STREAMLIT\kinopoisk\app.py
.
Step 3: Create a Streamlit Shortcut
- Right-click on the desktop → New → Shortcut.
- Enter:
cmd /k "F:\PYTHON\STREAMLIT\kinopoisk\.venv\Scripts\activate.bat && python -m streamlit run F:\PYTHON\STREAMLIT\kinopoisk\app.py"
- Click Next, name it (e.g., “Run Streamlit App”), and click Finish.
Note: cmd /k
keeps the window open to view Streamlit output. Use cmd /c
to close it after launch if preferred.
Step 4: Customize the Shortcut Icon (Optional)
- Right-click the shortcut → Properties.
- Click Change Icon, select an
.ico
file, and apply.
3. Running the Script with Administrator Privileges
If your script requires admin rights (e.g., for system-level operations):
- Right-click the shortcut → Properties.
- Click Advanced → Check Run as administrator.
- Click OK and Apply.
Double-clicking now prompts for admin approval, ensuring proper execution.
Examples of Shortcut Commands
Example #1: Streamlit Shortcut
cmd /k "F:\PYTHON\STREAMLIT\kinopoisk\.venv\Scripts\activate.bat && python -m streamlit run F:\PYTHON\STREAMLIT\kinopoisk\app.py"
Activates the virtual environment and runs a Streamlit app.
Example #2: Python Bot Shortcut
cmd /k "cd /d F:\PYTHON\BOTS\RollercoinBot-master && .venv\Scripts\activate.bat && python bot5.py"
Changes directory, activates the environment, and runs a bot script.
Watch this video for a visual guide: How to Create a Python Shortcut.
Conclusion
Creating a desktop shortcut for a Python script or Streamlit app simplifies your workflow, eliminating repetitive command-line steps. Whether it’s a basic script or a complex app with a virtual environment, these shortcuts make launching a breeze. Customize them with icons or admin privileges for added flexibility.

Professional data parsing via ZennoPoster, Python, creating browser and keyboard automation scripts. SEO-promotion and website creation: from a business card site to a full-fledged portal.