2017-06-19 142 views
1

我正在尝试创建一个ANT脚本,其中包括配置IIS。
为此,请尝试利用appcmd工具。但是得到一个奇怪的错误。 appcmd命令在蚂蚁脚本之外正常运行,但在内部失败。使用apache-ant向IIS运行操作系统命令配置

我使用Exec任务踢它全部关闭:

<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:\PTMP2\APPIAN17\\JAKARTA\\ISAPI\\ISAPI_REDIRECT.DLL', 
DESCRIPTION='JAKARTA',ALLOWED='TRUE']' is not supported. 
Run 'appcmd.exe /?' to display supported objects. 

然而,当我运行 如果I C该命令& p到DOS提示符下,它会高兴地运行:

C:\Windows\System32\inetsrv>appcmd set config /section:isapiCgiRestriction 
/+"[path='d:\ptmp2\appian17\\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" 

回答

1

需要逃脱si引用也很好。

也改变路径独立于/

使用如下:

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