Python · Industrial Automation

Schedule Python Excel Reports with Windows Task Scheduler

Schedule Python Excel, PDF and email reports automatically on Windows using Task Scheduler or schtasks. Run a Python script or packaged EXE on a daily schedule.

Practical Python Automation Context Copy-Paste Examples Code Architecture

Learning Overview

Python Learning SeriesPython for Industrial AutomationPractical

Learning Goal

  • Schedule Python Excel, PDF and email reports automatically on Windows using Task Scheduler or schtasks. Run a Python script or packaged EXE on a daily schedule.
  • Run the examples in VS Code using the project environment prepared in earlier topics.
  • Understand where this topic fits in the complete SQL, reporting and Industry 4.0 workflow.
Quick answer

Schedule Python Excel, PDF and email reports automatically on Windows using Task Scheduler or schtasks. Run a Python script or packaged EXE on a daily schedule.

Architecture: Schedule Reports Automatically

Code-Based Architecture

Schedule Reports Automatically

1

Trigger

Daily / shift / startup schedule

08:00 daily
2

Task Scheduler

Windows scheduling engine

Task
3

Python / EXE

Launch report program

python report.py
4

SQL Server

Read latest plant data

SELECT ...
5

Report

Generate Excel/PDF

D:\SQF_Reports
6

Log / Email

Record result or distribute

report.log
TriggerTask SchedulerPython / EXESQL ServerReportLog / Email

1. Prepare a non-interactive report program

Scheduled programs should not depend on manual input boxes. Put paths, database settings and report rules in configuration or validated constants.

2. Test the exact command manually

cd /d D:\SQF_Report
.venv\Scripts\python.exe report.py

Use the same executable and working directory that the scheduled task will use.

3. Task Scheduler fields

FieldExample
Program/scriptD:\SQF_Report\.venv\Scripts\python.exe
Add argumentsD:\SQF_Report\report.py
Start inD:\SQF_Report

4. Create a task with schtasks

schtasks /Create /SC DAILY /TN "SQF Daily Report" ^ /TR "D:\SQF_Report\SQF_Report.exe" /ST 08:00
Run and security settings depend on the Windows account and your organization’s policy.

5. Use an absolute output folder

from pathlib import Path
OUTPUT = Path(r"D:\SQF_Reports")
OUTPUT.mkdir(parents=True, exist_ok=True)

6. Scheduled-job checklist

  • Task account has SQL and folder permissions
  • Start-in folder is correct
  • ODBC driver exists on the machine
  • Logs record success/failure
  • Test task manually before production scheduling

Frequently Asked Questions

Can Task Scheduler run a Python script?

Yes. Configure the Python interpreter as the program and the script path as an argument, or schedule a packaged EXE.

Why does a script work manually but fail when scheduled?

Common causes include a different working directory, account permissions, missing environment variables or using another Python environment.

Should scheduled reports write logs?

Yes. Logs are important because the task may run unattended.

Reviewed by Bhawesh Kumar SinghIndustrial Automation Trainer and Industry 4.0 Consultant · Softwell Automation · 21+ years industry experience
Complete Python for Industrial Automation Learning Path

Use Previous / Next for sequential training, or open any topic directly.

Complete

Continue with the next topic in the Python for Industrial Automation learning path.

Open Learning Path
Python for Industrial Automation

Schedule Reports Automatically

Schedule Python Excel, PDF and email reports automatically on Windows using Task Scheduler or schtasks. Run a Python script or packaged EXE on a daily schedule.

Content reviewed: 14 September 2026

☎ Call WhatsApp ✉ Email Enquire Now