I have a VBS script which when run from the command line runs perfectly, but when I try to execute the script via CFEXECUTE
the script does not seem to run (the file which should be created is not created).
The following text appears in my browser window when I run the page containing the CFEXECUTE
tag:
Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. All rights reserved.
My code is:
<cfexecute name="C:\Windows\System32\cscript.exe" arguments="D:\path\to\script\myscript.vbs" timeout="30">
Does anybody know why it might not be running correctly?
Update:
If I use the code below instead of CFEXECUTE
the value of result
is 0, which I believe means the script ran without error. But the file which should have been created still hasn't been created.
<cfset command = "C:\Windows\System32\cscript.exe D:\path\to\script\myscript.vbs">
<cfset runTime = CreateObject("java","java.lang.Runtime").getRuntime()>
<cfset process = runTime.exec(command)>
<cfset result = process.waitFor()>
<cfoutput>#result#</cfoutput>
The VBS script:
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("D:\path\to\xls\file\containing\html.xls")
objExcel.Application.Visible = False
objExcel.Application.DisplayAlerts = False
objExcel.ActiveWorkbook.SaveAs "D:\path\to\new\xlsx\file.xlsx", 51
objExcel.ActiveWorkbook.Close
objExcel.Application.DisplayAlerts = True
objExcel.Application.Quit
WScript.Quit