Topic Options
#40609 - 09/10/12 03:57 PM Run Script Question
ampoole Offline
OL Newbie

Registered: 07/26/12
Posts: 21
Loc: Appleton, WI
Hi,
I created a VB.exe and would like to have that run within my Planetpress Production workflow. I keep getting errors. I know that I can import a .vbs file but how do I create that file out of Visual Studio? Here is my code, is there a way that I can modify it so that is runs in the workflow?

Public Class Form1
Inherits System.Windows.Forms.Form

Dim strLine As String
Dim intCounter As Integer
Dim intPages As Double = 0
Dim objStreamReader As System.IO.StreamReader
Dim objStreamWriter As System.IO.StreamWriter
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'open the file for input
objStreamReader = System.IO.File.OpenText("C:\Header Removed.txt")

'open the file for append
objStreamWriter = System.IO.File.CreateText("C:\Split Me.txt")


Do Until objStreamReader.Peek = -1
strLine = objStreamReader.ReadLine()

If InStr(strLine, "") Then
intPages = (Val(Trim(Mid(strLine, 36, 10)))) - 1
Do Until intPages = 0
objStreamWriter.WriteLine(strLine)
intPages = intPages - 1
Loop
End If


objStreamWriter.WriteLine(strLine)
Loop

'closes the input file
objStreamReader.Close()

'closes the output file
objStreamWriter.Close()

'display the message box
MessageBox.Show("Complete", "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2)

Me.Close()
End Sub
End Class

Top
#40610 - 09/10/12 04:28 PM Re: Run Script Question [Re: ampoole]
Raphael Lalonde Lefebvre Offline
OL Expert

Registered: 10/14/05
Posts: 4953
Loc: Objectif Lune Montreal
ampoole,

If you made a .exe, you can call it with the Run External Program. As for Run Script, note that vbscript isn't the same as normal VB, and just copy-pasting your code might not work. You'll have to check and make sure you have made a proper conversion from Visual Studio to a vbscript. (pretty sure you can find a lot about this on Google)

But either way, looking at your actual code, it will most likely not work at all in PlanetPress Workflow. PlanetPress Workflow will run as a service when it runs live, that is, silently in the background, and will not support programs that displays dialog boxes and wait for user inputs as you are doing. So even if you eventually get the script to execute without errors, what you are doing with it will not work, regardless of whether you call a .exe with Run External Program, or use a code in Run Script.

(NOTE: It's possible you might get it to work in Debug mode, but don't be fooled! When running in Debug, it runs it like an application, not a service. But live mode is a background service, so don't rely on anything you get in Debug!)

The only workaround I could propose is to compile your code as a .exe, then in PlanetPress Workflow, use a Run External Program action and call a batch file, which in turn will call your actual .exe. It will wait until the program closes before moving on with the rest of the process. This works well sometimes, but I've still seen cases where it glitches out, so it's still risky.

Finally, please note that neither scripts or external programs are officially supported. If you want us to assist you further with the integration of custom scripts and/or third party programs, you will have to purchase professional services.

Regards,
Raphaƫl Lalonde Lefebvre

Top