Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

How to execute a program in a persistent process from the Python tool?

Markus2
7 - Meteor

Within the Python tool I want to start a VBS script whose process shall survive the execution of the workflow, but I can't get that done. Maybe someone can help?

 

Attached a demo workflow together with a VBS script that just says "Hello". You can also find the  Python and VBS code further down in that message. The workflow just contains the Python tool, nothing else.

 

My observations are the following:

1) Whenever the workflow is run as a whole, the wscript.exe-process terminates after the Python tool has been executed.

2) When you execute the Python code within the Python tool, the then process persists.

 

PYTHON CODE START

import os

 

VbsScript = "Hello.vbs"

 

cmd = 'wscript.exe "' + os.path.join(Alteryx.getWorkflowConstant('Engine.WorkflowDirectory'),VbsScript) + '"'
cmd = '"' + os.path.join(Alteryx.getWorkflowConstant('Engine.WorkflowDirectory'),VbsScript) + '"'

 

os.popen(cmd)

PYTHON CODE END

 

VBS CODE START

MsgBox "Hello"

VBS CODE END

2 REPLIES 2
BrandonB
Alteryx
Alteryx

Can you try using a script to kick off another script? I think that the main script needs to terminate on workflow completion, but if you execute another script from that script you may be able to achieve your objective. 

Markus2
7 - Meteor

Hello Brandon,

thanks for your response. I also tried to work around that issue in that way, but unfortunately with the same result.

 

This is how it did:

  • In the Python script, I set
    VbsScript = "Text.vbs"
  • The script "Text.vbs" has been created in the workflows folder with code to call the Hello-script:
    VBS CODE START
    sScriptPath = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName) & "\Hello.vbs"
    Call CreateObject("WScript.Shell").Run("""" & sScriptPath & """")
    VBS CODE END

It is really astonishing, but again the process of the Hello-script terminates when running the workbook. Of course, when running just the Python notebook, the process survives.

 

Labels