5

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.

chungsangh
  • 353
  • 1
  • 4
  • 15
  • How are you configuring the task in task scheduler? Office isn't designed to run as a service, and needs to be run interactively. – Eric Brown Feb 03 '14 at 18:56
  • I'm pointing the Python script as an Action. I haven't changed anything other than the trigger, and allowing it to run while the user is not logged on with highest privileges. Any thoughts? – chungsangh Feb 03 '14 at 18:59
  • Yes - you can't do that with Office. :( The *only* way you'll get that to work is to run as the currently logged-in user, on the current user's desktop, with the current user's privileges. – Eric Brown Feb 03 '14 at 19:01
  • @EricBrown Thank you so much! I think that will do for now. I'm hoping it will run while the computer is "Locked", but not logged off. If you reply to the thread with your comment, I can select it as a solution since it is what I wanted to do :) – chungsangh Feb 03 '14 at 19:47

1 Answers1

6

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.

Eric Brown
  • 13,774
  • 7
  • 30
  • 71
  • This saved my day! On one hand, it is quite obvious that graphical applications do not work for non-logged users, but the generic error I was getting for recent days did not help me in any way understand that it wast this problem (in my case MS Excel). Running under logged-in user works as expected. Thanks! – Jakuje Nov 10 '17 at 21:19