Solved

Passing Arguments using CFExecute and a VBS File

Posted on 2004-08-10
4
1,322 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

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

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

617 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