2

我在 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

它只显示“完成!” 没有任何错误,它不会执行添加站点代码。

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

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

请帮助任何想法/建议。

谢谢。

4

1 回答 1

1

如果 appcmd.exe 从 cmd.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 使用变量。

于 2011-12-13T06:05:25.617 回答