使用CFExecute运行VBScript会抛出错误,但通过命令行可以正常工作

使用CFExecute运行VBScript会抛出错误,但通过命令行可以正常工作,vbscript,coldfusion,wsh,cfexecute,Vbscript,Coldfusion,Wsh,Cfexecute,我试图运行VBScript,但CFExecute抛出错误 <cfexecute name = "C:\Windows\System32\CScript.exe" arguments = "//NoLogo D:\Excel.vbs D:\test.xls" variable = "data" timeout = "100"> </cfexecute> <cfdump var="#data#"

我试图运行VBScript,但CFExecute抛出错误

<cfexecute name = "C:\Windows\System32\CScript.exe" 
            arguments = "//NoLogo D:\Excel.vbs D:\test.xls"
            variable = "data"
            timeout = "100">
 </cfexecute>
<cfdump var="#data#">
但是当我用CMD运行VBScript时,它工作得很好

C:\Windows\System32 > cscript //nologo D:\Excel.vbs D:\test.xls
我有完全的管理员权限,为什么会出现此错误?

创建vbscirpt文件(.vbs)。代码内容将具有您想要实现的任务

下面的示例包含刷新excel的vbscript文件和执行vbscript的cfm

vbscript文件代码示例:-

Set fso = CreateObject("Scripting.FileSystemObject")
Set xl  = CreateObject("Excel.Application")
xl.Visible = True

For Each f In fso.GetFolder("C:\inetpub\WebSites\Upload\").Files
  If LCase(fso.GetExtensionName(f.Name)) = "xlsx" Then
    Set wb = xl.Workbooks.Open(f.Path)
    wb.RefreshAll
    wb.Save
    wb.Close
  End If
Next

xl.Quit
<cfexecute name = "C:\Windows\System32\cscript.exe" arguments = "C:\inetpub\WebSites\CSAT\test.vbs">
</cfexecute>
示例cfm文件代码:-

Set fso = CreateObject("Scripting.FileSystemObject")
Set xl  = CreateObject("Excel.Application")
xl.Visible = True

For Each f In fso.GetFolder("C:\inetpub\WebSites\Upload\").Files
  If LCase(fso.GetExtensionName(f.Name)) = "xlsx" Then
    Set wb = xl.Workbooks.Open(f.Path)
    wb.RefreshAll
    wb.Save
    wb.Close
  End If
Next

xl.Quit
<cfexecute name = "C:\Windows\System32\cscript.exe" arguments = "C:\inetpub\WebSites\CSAT\test.vbs">
</cfexecute>

是的。 对于办公自动化(通过脚本和非基于窗口的操作进行访问),我们必须在其中添加一个“桌面”文件夹

C:\Windows\System32\config\systemprofile
C:\Windows\SysWOW64\config\system32

我添加了它并获得了成功。

您拥有完全的管理员权限。。。但是ColdFusion正在运行的帐户有吗?@AdamCameron有。将完整的命令和参数粘贴到批处理文件中,然后
。使用批处理文件检查:@echo off pushd%~dp0 cscript//nologo D:\Excel.vbs D:\sham.xls相同的错误,让我在此处与网络管理员检查一下。酷。我将手动确认帐户CF正在运行,因为它具有适当的有效权限。不要假设:检查。只是把它作为一个因素去掉。好的,但我已经解决了我目前的问题。将立即添加注释以发布解决方案。只是好奇,您是否必须在这两个位置创建“桌面”子文件夹?该线程根据您的o/s使其听起来像这样,即64位的
SysWOW64
,32位的
System32
。是的,需要在两个目录中创建@Leigh桌面文件夹。