We help IT Professionals succeed at work.

cfexecute and bat files

Last Modified: 2013-12-24
I have a unique problem in that I need to convert pdf pages to jpegs on the fly as users upload them. So far all my research points to a piece of software called pdf2img by http://verypdf.com. What makes it so useful is that you can run it from the command line. See http://www.verypdf.com/pdf2tif/pdf-to-image/help.htm for commands. I was hoping it would be an easy task using cfexecute on my CF7 server. So far not so good. I have never used cfexecute or bat files. Research so far has been pretty geeky so far and not directly related to my current task at hand.

When I run the following command from the command line I get the output I desire.
-i F:\test.pdf -o F:\output.jpg -f 1 -l 1

This outputs the first page of the PDF as a jpg. No problem. The problem occurs when I try to add this command to a .bat file and run it from the web with a script like so.


My .bat file has changed wildly in the last day so I won't even post an example here as I believe this is where the problem is. I have no idea how to launch the exe located at C:\Program Files\VeryPDF PDF2Image v2.1\pdf2img.exe

Any help is greatly appriciated.
Watch Question

Try this in a batch file:


ECHO Waiting...
"C:\Program Files\VeryPDF PDF2Image v2.1\pdf2img.exe -i F:\test.pdf -o F:\output.jpg -f 1 -l 1"



Not quite it yet.

I would like to add that from the CMD terminal I had to CD into the C:\Program Files\VeryPDF PDF2Image v2.1\ to run the pdf2img.exe

I am not sure if this is typical, or how things are typically done from the terminal do I have to change directories in the scripting for the .bat file or can you not run the exe with a full path like above?

Thanks for the help so far. I appreciate it greatly.

If you use the full path name as above with the quotes, it should run. Does this answer your question?

Also make sure to copy everything in between the two lines, including the last empty line.

I think wizeabe's command would work better like this
"C:\Program Files\VeryPDF PDF2Image v2.1\pdf2img.exe" -i F:\test.pdf -o F:\output.jpg -f 1 -l 1

The quotes only need to be around the exe your trying to run (Or more the point the command with spaces in it).
The EXE itself will parse the rest of the commands itself.

IF however the directory your inputting from or outputting to has spaces then the command would be this.
"C:\Program Files\VeryPDF PDF2Image v2.1\pdf2img.exe" -i "F:\this is a test\test.pdf" -o "F:\this is a test\output.jpg" -f 1 -l 1


Thanks for that, I didn't have a utility like that with me to test my command.
Unlock this solution and get a sample of our free trial.
(No credit card required)


Just wanted to follow up and say that the accepted answer worked perfectly. I did find one problem that may effect others trying to do the same thing.

I am running  CF Server on my user account  and by default, the server cannot interact with the system and therfore cannot run tha bat or run a command line process. CFServer has to be run as an admin or you will need to go to the properties of that service and check the box for allowing the service to interact with the desktop under the log on tab. and restart the service. I am sure this is a big security problem and I am looking for a better solution. Thanks again guys for all the responses.

Thanks visual28,
For my own curiosity which one of the options worked for you?



No Problem Terry,

They both worked fine however this one worked best as it would allow me to set the input and output values dynamically using a variable.

<cfexecute name="C:\Progra~1\VeryPD~1\pdf2img.exe"
  arguments="-i F:\test.pdf -o F:\output.jpg -f 1 -l 1"

Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.