【问题标题】:CFExecute not executing appcmd.exeCFExecute 不执行 appcmd.exe
【发布时间】:2026-01-17 09:55:01
【问题描述】:

我在 Cofdfusion 服务器上创建了以下代码:文件名:testWebsite.cfm

<cfoutput>
<cfset exec_command = "add site /name:""demosite"" /bindings:http://demosite.testserver.com:80 /physicalpath:""D:\Websites\demosite"" ">

<cfexecute name="C:\Windows\System32\inetsrv\appcmd.exe" arguments="#exec_command#" timeout="60" />

Done!
</cfoutput>

但是当我执行这个文件时,例如http://www.demoserver.com/testcases/testWebsite.cfm

它只显示“完成!”没有任何错误,它不会执行 add site 代码。

在参考了许多文档后,我检查了两者执行的用户权限。 coldfusion 服务 以名为 Webserver@domain.com 的域用户身份运行 我不知道如何检查 IIS。 所以我检查了 World Wide Publishing ServiceIIS Admin Service - 作为 Local System 运行。

即使我以管理员身份登录,我也无法将 webserver 用户 添加到 inetsrv 文件夹或位于以下位置的 appcmd.exe C:\Windows\System32

请提供任何想法/建议。

谢谢。

【问题讨论】:

    标签: iis-7 coldfusion-9 appcmd cfexecute


    【解决方案1】:

    如果从 cmd.exe 调用 appcmd.exe,它应该可以工作:

    <cfset vcCmdPath = "C:\Windows\system32\cmd.exe">
    <cfset vcAppCmdArg = "/c C:\Windows\System32\inetsrv\appcmd.exe">
    <cfset exec_command = "add site /name:""demosite"" /bindings:http://demosite.testserver.com:80 /physicalpath:""D:\Websites\demosite"" ">
    
    <cfexecute name="#vcCmdPath#" arguments="#vcAppCmdArg# #exec_command#" variable="vcAppCmdResults" timeout="60"></cfexecute>
    
    <cfoutput>#vcAppCmdResults#</cfoutput>
    

    我更喜欢为 cmd.exe 和 appcmd.exe 使用变量。

    【讨论】: