Solved

Passing Arguments using CFExecute and a VBS File

Posted on 2004-08-10
4
1,305 Views
Last Modified: 2013-12-24
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

0
Comment
Question by:craines1976
  • 2
4 Comments
 
LVL 21

Expert Comment

by:pinaldave
ID: 11766458
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
0
 

Author Comment

by:craines1976
ID: 11766599
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?
0
 
LVL 9

Accepted Solution

by:
shooksm earned 500 total points
ID: 11766721
Try this:

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

Expert Comment

by:shooksm
ID: 11775775
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.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question