I am working on calling a .exe file with a WScript.shell activeX. The file is wkhtmltopdf.exe and it is used to convert a HTML page to a .pdf. Everything is working well when I am just calling C:wkhtmltopdf.exe in the code. It runs and then closes correctly. But my issue is you need to run it from cmd with the program name then the HTML file name you are reading followed by the .pdf name you want it to be created as.
For example:
c:wkhtmltopdf.exe c:PDFTestPage.html c:TEST.pdf
This will call wkhtmltopdf.exe, read c:PDFTestPage.html, then create c:TEST.pdf. Works fine when I type it into cmd.
Does anyone know an activeX that will not just run and .exe but actually execute a command line?
Here is my code that I am currently using.
function callShellApplication(){
var objShell = new ActiveXObject("WScript.shell");
objShell.run('"c:wkhtmltopdf.exe"');
}
Would really like it to be the following.
function callShellApplication(){
var objShell = new ActiveXObject("WScript.shell");
objShell.run('"c:wkhtmltopdf.exe c:PDFTestPage.html c:TEST.pdf"');
}
Also side note. For some reason I cant launch the .exe from an absolute path. I have to move to the directory and then just type in wkhtmltopdf.exe. The fill path is:
C:Program Files (x86)wkhtmltopdfwkhtmltopdf.exe
I really only work with UNIX so I'm not sure about spaces in the path. I can do a chdir with the spaces but I cant use the fill path when executing it. Any information would be helpful. Thank you in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…