Skip to main content
Participant
September 17, 2013
Question

Run/Start .Exe file in ColdFusion

  • September 17, 2013
  • 1 reply
  • 4669 views

Hi guys,

am trying to open up a .exe file like notepad or whatever windows program with using <cfexecute> but seems it doesn't work at all. I'm able to write the command in cmd and run the exe file but when i put the command in cfexecute so i get nothing.

here is the command i would like to run:

"C:\Program Files (x86)\Vc\vc.exe" -e "\Crystal\BF_Faktura_D.rpt"

altso, run/start a simple .exe windows program. I think there is something about security access from CF server or something like that.

ANY HELP?

This topic has been closed for replies.

1 reply

Legend
September 17, 2013

Hi,

Here's how I do this:

<cfexecute name="C:\Windows\System32\cmd.exe" arguments="/C C:\batchfile.bat" timeout="999"></cfexecute>

where batchfile.bat contains the commands to run. No other changes were made to the CF server to allow this to work.

Regards,

Mark

Participant
September 17, 2013

this is what i have in my .bat/.cmd file:

"C:\Program Files (x86)\Vc\vc.exe" -e "\Crystal\BF_Faktura_D.rpt"


And i would like to remove that batch file totaly and run the command directly from CF to be able to make a HTML form and put some inputs through that form.

here you can see what i really do in bat file:

echo parameters:

echo      fakturagruppe  : %1

echo      fakturanr(fom) : %2

echo      fakturanr(tom) : %3

"C:\Program Files (x86)\Visual CUT 11\Visual CUT.exe" -e "\BF_Faktura_D.rpt" "Parm1:%2>>>%3>>>3" "Parm2:false" "Parm3:%1" "Parm4:false"

"Export_File:\\bf-visma02\vismadata\vbdoc\F0001\Fakturakopi\IC{BF_Faktura_S.InvoNo}.pdf" "Export_Format:Adobe Acrobat (pdf)"

I would like to open Visual cut.exe through CF to be able to make thos parameters in an HTML form instead of inputs from .bat file as you see!

Legend
September 17, 2013

You can't remove the batch file totally because you have to run the DOS commands contained within it. Also, ColdFusion is not run like a DOS batch file; calling a .cfm template is not like taking arguments from a command line.

I think what you mean is that you want to pass parameters from a form to the batch file, in which case all you have to do is substitute in the ColdFusion parameter. So you need two pages, one with the HTML form, and one with the CF page with the <cfexecute> in it.

For example you could do this:

file 1: file1.cfm

<form method="post" action="file2.cfm">

Param 1 <input type="text" name="param1" value="C:\batchfile.bat" />

</form>

file 2: file2.cfm

<cfexecute name="C:\Windows\System32\cmd.exe" arguments="/C #Form.param1#" timeout="999"></cfexecute>

which would substitute "C:\batchfile.bat" into the <cfexecute> tag, to allow you to run different batch files. This is just a simple example to show you how to substitute a value.

Btw, CF can create PDFs - if you can use CF throughout, that would be a better solution than calling a batch file.