Cfexecute problem
I have batch file which run script to convert word to pdf .When directly run batch file conversion done perfectly.
When I try to use coldfusion cfexecute to run the batchfile it take continuously execute until browser close no error and no output .
My cfm file and bat file location is D drive
<cfexecute name="C:\Windows\System32\cmd.exe" timeout="2000">
cd /D D:\home\docxtopdf
bulk-convert-Word2PDF.bat
</cfexecute>
My batch file :
echo off
for %%X in (*.docx) do cscript.exe //nologo SaveAsPDF.js "%%X"
for %%X in (*.doc) do cscript.exe //nologo SaveAsPDF.js "%%X"
My SaveAsPDF.js
ar obj = new ActiveXObject("Scripting.FileSystemObject");
var docPath = WScript.Arguments(0);
docPath = obj.GetAbsolutePathName(docPath);
var pdfPath = docPath.replace(/\.doc[^.]*$/, ".pdf");
var objWord = null;
var wdAlignPageNumberCenter = 1;
var wdPageNumberStyleLowercaseRoman=46
try
{
objWord = new ActiveXObject("Word.Application");
objWord.Visible = false;
var objDoc = objWord.Documents.Open(docPath);
objDoc.Sections(1).Footers(1).PageNumbers.Add(wdAlignPageNumberCenter);
objDoc.Sections(1).Footers(1).PageNumbers.NumberStyle = wdPageNumberStyleLowercaseRoman;
var format = 17;
objDoc.SaveAs(pdfPath, format);
objDoc.Close();
WScript.Echo("Saving '" + docPath + "' as '" + pdfPath + "'...");
}
finally
{
if (objWord != null)
{
objWord.Quit();
}
}
Help me with some solution to work with it
