I'm having issues running a .py file with Windows Task scheduler. Task runs perfectly fine when ran manually through task scheduler. When scheduled, the error I get is “pyautogui.FailSafeException: PyAutoGUI fail-safe triggered from mouse moving to a corner of the screen.” I know its not recommended but I gave pg.FAILSAFE = FALSE a shot. However, this does not run the application that I tell the script to run. No errors in python. No errors in Windows task. Both say successful. I know when my connection disconnects, my mouse is moved to the corner of the screen which is why I'm getting the errror. However, putting pg.FAILSAFE = FALSE prevents the CTRL R.
Expected workflow:
Windows task schedule executes my .py file > Python launches my Alteryx file (yxmd) > Python runs my Alteryx file > I get some output.
Current workflow:
Windows task scheduler executes my .py file > Python launches my Alteryx file (yxmd) > Python does not run my Alteryx file. (this is when pg.FAILSAFE = FALSE is applied. When not applied, I get the fail safe error)
Windows scheduler settings:
- Run only when user is logged in
- Configured for Windows Server 2016
- Server account is the User account running the task
- Program Script: C:\Users\username\[PythonScript].py
- Add arguments: Blank
- Start in: Blank
- Scheduled daily
Python Script:
import pyautogui as pg
import os
import time
time.sleep(10)
os.startfile(r'C:\Users\[FileName].yxmd')
time.sleep(60) #build in enough time for Alteryx to open the workflow
pg.hotkey('ctrl', 'r')
time.sleep(10)
CodePudding user response:
