How to Automatically Run Python Scripts with Windows Task Scheduler (Silently!)

Ever wanted your Python scripts to run automatically — every hour, every morning, or after reboot? You don’t need to keep your terminal open or build a full app for that. Windows Task Scheduler can handle it for you — and you can even run your scripts silently in the background.

In this post, we’ll cover:

  • How to schedule a .py file to run automatically
  • How to run it without opening a Command Prompt window
  • What’s the difference between python.exe and pythonw.exe

Step 1: Yes, You Can Schedule Python Scripts!

Windows Task Scheduler is a built-in tool that lets you automate Python scripts to run:

  • At a specific time (e.g. 7:00 AM)
  • On a recurring basis (e.g. every 30 minutes)
  • At startup or login
  • After an event (e.g. system idle)

This means you can automate scripts for:

  • Sending emails
  • Scraping websites
  • Running trading bots
  • Updating spreadsheets
  • Cleaning up files
  • Pulling API data

Step 2: How to Set It Up in Task Scheduler

  1. Open Task Scheduler from the Start Menu.
  2. Click “Create Task…” (not “Basic Task”).
  3. Under the General tab:
    • Give it a name (e.g. “Run My Script”)
    • Select “Run whether user is logged on or not” if needed
  4. Go to the Triggers tab and click New…
    • Choose how often it runs (daily, hourly, at startup, etc.)
  5. Go to the Actions tab and click New…

Three Key Fields in the Actions Tab

Here’s how to fill out the three main fields:

FieldWhat to Enter
Program/scriptFull path to Python interpreter (python.exe or pythonw.exe)
Add argumentsThe full path to your .py or .pyw script in quotes
Start inThe folder path (directory) where your script is located (no trailing slash)

Example:

  • Program/script: C:\Users\YourName\AppData\Local\Programs\Python\Python311\pythonw.exe
  • Add arguments: my_task.py
  • Start in: C:\Scripts\

By Default, the Script Pops Up a Window

If you use python.exe, Task Scheduler will open a black Command Prompt window every time your script runs. That’s fine for testing, but distracting for background tasks.


Step 3: Run Silently with pythonw.exe

To suppress the command window, just switch to pythonw.exe in the Program/script field.

ExecutableDescriptionShows Terminal?
python.exeDefault Python interpreter (CLI)✅ Yes
pythonw.exeWindows GUI-friendly version (silent)❌ No

You can continue using .py files — there’s no need to rename them to .pyw.


Recap

To schedule Python scripts and run them silently:

  • Use Windows Task Scheduler
  • Point to your Python interpreter and script path
  • Use pythonw.exe for background execution
  • Set the “Start in” field to your script folder

That’s it — no pop-ups, no interruptions.


Pro Tip:

This method works great for background jobs, bots, scrapers, automation scripts, and more — all without installing extra software.

Sharing

Related Articles

  • All Post
  • Articles
  • Blog Post
  • General Business Automation
  • Portfolio
  • Stock Market & Finance