2017-06-19 66 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>