Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Run workflow using Windows task scheduler

NITESH_KUMBHARE
6 - Meteoroid

I have Alteryx workflow saved in my machine.

Due to internal restrictions in my organisation, I am unable to use "workflow schedule" feature of Alteryx.

 

Hence to get an Alternative solution. I am planning to run workflow using Task Scheduler of Windows.

Could you tell me what is the process?

 

Thanks

 

17 REPLIES 17
BrandonB
Alteryx
Alteryx

Hi @NITESH_KUMBHARE 

 

Your organization will want to look into Alteryx Server for centralized deployment and scheduling of workflows. The Alteryx Server also has an API and command line capabilities if you would like to integrate workflows into other enterprise processes. 

 

You can read more in the data sheet here: https://www.alteryx.com/sites/default/files/2021-03/Alteryx-Server-Datasheet.pdf 

phottovy
13 - Pulsar
13 - Pulsar

Hi @NITESH_KUMBHARE,

 

I agree with @BrandonB that Alteryx Server is the best long term solution but I also have another option that I previously utilized using the task scheduler:

 

Step 1: Download and add CReW Macros to your version of Alteryx. Then setup the "List Runner" macro to run the workflows you are hoping to schedule.

 

Step 2: Create a simple python script that will open and run your workflow containing the "List Runner" macro. I use the pyautogui library to start the workflow by simulating pressing "Ctrl + r". Here is the script that I created which I called "Run_Alteryx_Workflow.py":

import pyautogui as pg
import os
import time

time.sleep(10)
os.startfile('Scheduler.yxmd')
time.sleep(60) #build in enough time for Alteryx to open the workflow
pg.hotkey('ctrl', 'r')
time.sleep(10)

 

Step 3: Create a batch script to run your python script. Here is my version called "Run_Alteryx_Workflow.bat". This file should be saved in the same folder as your python script:

"python" "Run_Alteryx_Python.py"

 

Step 4: Schedule your batch script to run in Task Scheduler.

 

There are definitely issues with this process though. I don't have admin rights on my work computer so my computer needed to be awake to run this process. I'm sure there are many ways to improve this process but this is one I tried a few years ago.

Joma
7 - Meteor

Thanks for sharing the approach.

 

I am using this tutorial, but I am struggling with step 3. 

"python" "Run_Alteryx_Python.py"

 

If I understood it correctly for "python" I need to have python installed and enter my lokal path of the python.exe here? Or can I use the Alteryx Designer here as I don´t have Python installed atm?

I tried it with my local path for the Alteryx Designer and it opens the Python Workflow in Alteryx, but won´t run it. Is there a way to get this running with Alteryx Designer or do I need Python on my local device?

 

Thanks for your help in advance.

 

 

phottovy
13 - Pulsar
13 - Pulsar

Hi @Joma ,

 

You are correct about step 3. In this method, python would need to be installed on your machine outside of Alteryx. Without Alteryx Server, I don't believe there is a way to directly initiate a workflow to run using the Task Scheduler. To get around this, I am initiating a python script (outside of a workflow) by the Task Scheduler. This script will first open the Alteryx workflow and then run the workflow. If I tried to use the python tool inside an Alteryx workflow, I still wouldn't have a method to initiate the workflow to run.

Joma
7 - Meteor

Hi @phottovy, thank you for your fast reply. 


Yeah that was my logical error that I tried to perform it inside an Alteryx Workflow with a Python script. So i followed as suggested and it works. 
One question is still left though. How could i adapt the Python Script so that Alteryx will be closed after running? Looks like there is not really a function for closing the file? From my research it looks like i might need to use another way than using os.startfile?

 

 

phottovy
13 - Pulsar
13 - Pulsar

There is probably a way to close it with the os library but the easier approach might be to add this script to the end. You would have to add a long enough delay for your workflow to finish running though.

time.sleep(?)  #this would need to be long enough for your workflow to finish running
pg.press(['alt', 'f', 'x'], interval=0.25) #this is the keyboard shortcut to close Alteryx

 

Joma
7 - Meteor

Thanks again. Looks really promising! I slightly increased the interval to 0.50 and it worked 🙂

rommell
5 - Atom

To those who don't want to install python, here's what I currently do. The script below saved as .vbs file and triggered from windows task scheduler.

 

dim shell

set shell = createobject("wscript.shell")

shell.run("""alteryx path\alteryxgui.exe""" """workflow full path"""

wscript.echo "don't do anything for a few seconds. i'm about to run a scheduled workflow."

wscript.sleep 20000 '- depends how fast your machine is

shell.appactivate "alteryx designer"

shell.sendkeys "^r"

set shell = nothing

regena
5 - Atom

Super helpful but I keep getting and error about a ")" in the wrong spot or something.  are the 3 """ quotes required? any reason you don't have a close parenthesis?

Labels