Link to home
Start Free TrialLog in
Avatar of craines1976
craines1976

asked on

Passing Arguments using CFExecute and a VBS File

I am trying to use CFExecute to launch a VB Script file which converts docs serverside to pdf (ActivePDF software).  When I run the following, it will execute the script and convert a hard coded document in my code to PDF:

<cfexecute name="wscript.exe" arguments="c:\site\htdocs\activepdf\word_slug.vbs"/>

When I add the argument (TestDoc6.Doc) in it looks like:

<cfexecute name="wscript.exe" arguments="c:\site\htdocs\activepdf\word_slug.vbs TestDoc6.Doc"/>

But when the vbs file is run, it doesn't pick up the argument.  If I run it from the command line as: C:\word_slug.vbs TestDoc6.Doc,  it will pick it up.    

I tried to run the script this way in coldfusion:

<cfexecute name="wscript.exe c:\site\htdocs\activepdf\word_slug.vbs" arguments = "TestDo6.Doc"/>

but it gives me a NT Error Code 123 error.

This is what I am using to pick up the argument and the code to do the conversion:
*******************
Function CommandLine(Number)
  Set Arguments = WScript.Arguments
  If Number <= Arguments.Count Then
    CommandLine = Arguments(Number - 1)
  Else
    CommandLine = ""
  End If
End Function



arrayScr = Split(WScript.ScriptFullName, "\", -1, 1)
For i = 0 to UBound(arrayScr) - 1
   strPath = strPath & arrayScr(i) & "\"
Next

Set APServer = CreateObject("APServer.Object")
wordpath = strPath & CommandLine(1)
APServer.OutputDirectory = strPath
APServer.SetOutputSecurity "", "", False, False, False, False
'APServer.SetViewMode 0, 1, "Fit"

i = APServer.StartPrinting()

If (i <> 0) Then
Set APServer = Nothing
ConvertWordToPDF = ""
msgbox "could not start printing"
End If

********************

Thanks in advance

Avatar of pinaldave
pinaldave
Flag of India image

Hi craines1976,
I had once similar problem before (years before).
we added everything into the cfexecute  like <cfexecute name="wscript.exe c:\site\htdocs\activepdf\word_slug.vbs TestDoc6.Doc">
I am not sure if you can use that in your application or it is not supported by CF any more or VB but just for kicks you can try that.

Regards,
---Pinal
Avatar of craines1976
craines1976

ASKER

Pinal

I tried the command:

 <cfexecute name="wscript.exe c:\site\htdocs\activepdf\word_slug.vbs TestDoc6.Doc"/>

and got the following error:

*************
Cannot execute wscript.exe c:\site\htdocs\activepdf\word_slug.vbs TestDoc6.Doc

Windows NT error 123 occurred.

*************

I can't believe this is so tough with CF!  Is there a way to skip the Wscript.exe part like you can do on the command line?  i.e.  Just have <cfexecute name="word_slub.vbs" argument = "TestDoc6.Doc"/>  Why do you have to call the .exe and the vbs in CF but not on the command line?
ASKER CERTIFIED SOLUTION
Avatar of shooksm
shooksm

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
A quick question.  If ActivePDF is a COM object, why not just instantiate it and use it directly in Cold Fusion?  If you need help converting some of the VBScript to its Cold Fusion equivalent, just let us know.