Alteryx Designer Desktop Discussions

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

Can't figure out how to run a bat file or vbs script from the Run Command tool

JohnTdata
5 - Atom

I'm pretty used to using the Workflow Configuration -> Events tab to fire a .bat file to run at the end of a module.

 

But what if I want to run the same bat file halfway through the module? I tried the Run Command, and pointed it towards my bat file, but the tool errors because it complains about needing inputs and outputs. I got confused and gave up. A lot of stuff in Alteryx is obvious, intuitive and clear. The Run command, alas, is not.

 

So how do I fire up a bat file within a module in the same way that you would if you put it in the Events tab?

 

My bat file is super simple, and just calls a vbs file, which in turn calls an Excel macro.

 

Here is the bat file:

 

 

@echo off
C:\Windows\SysWOW64\cmd.exe /c
cscript "C:\Temp\script.vbs"

 

 

And here is the vbs file called above. I realise it's a bit roundabout going from bat file -> vbs -> Excel macro, but it works, and for me that's all that matters.

 

Option Explicit

On Error Resume Next

ExcelMacroExample

Sub ExcelMacroExample() 

  Dim xlApp 
  Dim xlBook 

  Set xlApp = CreateObject("Excel.Application") 
  Set xlBook = xlApp.Workbooks.Open("C:\Temp\Workbook.xlsm", 0, True) 
  xlApp.Run "Macro1"
  xlApp.Quit 

  Set xlBook = Nothing 
  Set xlApp = Nothing 

End Sub 

So my question is really why can't I just plug my bat file into the Run Command in the same way that I can run it from the Events tab?

 

Thanks!

 

3 REPLIES 3
patrick_digan
17 - Castor
17 - Castor

@JohnTdata I feel your pain. Wherever you want to insert your run command, I would connect that path to the run command tool, and then setup your run command tool to just output to %TEMP%dummyfile.yxdb. then you can input your bat file in the command section of the run command tool. Then I would setup your read results section of the run command tool to read that same dummy file.

Capture.PNG

 

StephenR
Alteryx
Alteryx

You can use a Text Input or formula tool to construct the batch script (line by line), then that will go into your output which will write it as a .bat which the cmd tool can then read.  I've attached an example.

Regards,
Stephen Ruhl
Principal Customer Support Engineer

vcheema
5 - Atom

Can we do something similar for vbs files. I have never got cscript to work on server.always get an error 1.

Labels