Solved

Passing Arguments using CFExecute and a VBS File

Posted on 2004-08-10
4
1,262 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
remove Handler and Add Handler for one file 3 32
Nginx CDN 12 114
connection string question 2 66
Public IP Address Amazon Servers 2 14
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now