使用 apache-ant to IIS 配置运行操作系统命令



我正在尝试创建一个ANT脚本,该脚本将配置IIS。
为此,请尝试利用appcmd工具。但是得到一个奇怪的错误。appcmd命令在 ant 脚本外部运行正常,但在 ant 脚本中失败。

我正在使用执行任务来启动这一切:

<exec dir="C:\Windows\System32\inetsrv\" 
executable="C:\Windows\System32\inetsrv\appcmd.exe" output="d:out.txt"> 
<arg value="appcmd set config /section:isapiCgiRestriction /+&quot;
[path='${appian_home}\jakarta\ISAPI\isapi_redirect.dll',
description='Jakarta',allowed='True']&quot;" />
</exec>

通过ANT捕获的输出是:

Object 'APPCMD SET CONFIG /SECTION:ISAPICGIRESTRICTION /+?
[PATH='D:PTMP2APPIAN17\JAKARTA\ISAPI\ISAPI_REDIRECT.DLL',
DESCRIPTION='JAKARTA',ALLOWED='TRUE']' is not supported. 
Run 'appcmd.exe /?' to display supported objects.

但是当我跑步时如果我将该命令c&p到dos提示符,它将愉快地运行:

C:WindowsSystem32inetsrv>appcmd set config /section:isapiCgiRestriction 
/+"[path='d:ptmp2appian17\jakarta5\ISAPI\isapi_redirect.dll',descripti
on='Jakarta',allowed='True']"
Applied configuration changes to section 
"system.webServer/security/isapiCgiRestriction" for 
"MACHINE/WEBROOT/APPHOST" at configuration commit path "M   
ACHINE/WEBROOT/APPHOST"

也需要转义单引号。

还更改了与/分开的路径

在下面使用:

<exec executable="cmd.exe" dir="C:/Windows/System32/inetsrv" failonerror="true">
    <arg line="/c appcmd set config /section:isapiCgiRestriction /+&quot;[path=&apos;${appian_home}/jakarta/ISAPI/isapi_redirect.dll&apos;,description=&apos;Jakarta&apos;,allowed=&apos;True&apos;]&quot;"/>
</exec>

最新更新