Python script involving Outlook through win32com runs when double-clicking, but not through task scheduler

StackOverflow https://stackoverflow.com/questions/21535376

  •  06-10-2022
  •  | 
  •  

Question

I have a python script that sends out an email using win32com and Outlook. The script runs without a hitch when I run it through an interpreter or double-click on the script. However, when I run it through the Task Scheduler, I get the following message:

"Something went wrong. We couldn't start your program. Please try starting it again. If it won't start, try repairing Office from 'Programs and Features' in the Control Panel."

I'm using Office 365, and Python 2.6. I've tried running the script through the scheduler after killing the Outlook process, but I ran into the same issue.

Was it helpful?

Solution

Office isn't designed to run as a service, and needs to be run interactively. You'll need to change your task configuration in Task Scheduler to run the task as the currently logged-in user, on the current user's desktop, with the current user's privileges.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top