Skip to main content
How do you configure workflow to kickoff a batch file or program executable from a server directory? I have a client who is trying to have this be the final activity in the workflow.
Hi Josephd,

I have used the System.Diagnostics.Process assembly to start an external application from within a K2.net server event. I'm not sure if this is the best way to do it but it has been working for me. The only catch to this is that if you require the .exe UI to appear in the foreground on the desktop, the K2.net Server Service needs to be run as a Local System Account with "Allow service to interact with desktop" enabled.

 
Dim myProcess As System.Diagnostics.Process = New System.Diagnostics.Process()
myProcess.StartInfo.FileName = "C:TempAsyncAsyncstub.exe"
' Following line is required to pass the SerialNumber to external app
' to facilitate a call-back during an Asynchronous Server event
' If your application need not perform a call-back, you may exclude it
myProcess.StartInfo.Arguments = K2.SerialNumber.ToString

myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal
myProcess.Start

Do you just create a code page in K2 Studio? How do you associate the workflow to that code? Thank you for the tip!

Best Regards,

Joe
You can use a Default Server Event by dragging one into an Activity. Right-click on the Default Server Event, and jump into the properties page. And in the Event Item, select to Use Code, then click Edit Code to go into the code editor view which will show you the blank code page for the Default Server Event. This is where you can drop in the sample code.

I know this is a really old post but I am trying to call a batch file from a workflow in Studio but when I add a server event I cannot seem to add any ocde to this. Is there some way to do this in K2 4.7?

 

 


Reply