Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Passing Arguments using CFExecute and a VBS File

Posted on 2004-08-10
4
Medium Priority
?
1,342 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

886 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