【问题标题】:Running an OS command using apache-ant to IIS config使用 apache-ant 运行 OS 命令到 IIS 配置
【发布时间】:2017-06-19 09:50:54
【问题描述】:

我正在尝试创建一个 ANT 脚本,其中包括配置 IIS。
为此,请尝试利用 appcmd 工具。然而得到一个奇怪的错误。 appcmd 命令在 ant 脚本之外运行良好,但在内部失败。

我正在使用 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.

但是当我跑步时 如果我将该命令 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"

【问题讨论】:

    标签: ant iis-7 appcmd


    【解决方案1】:

    也需要转义单引号。

    还将路径更改为/

    在下面使用:

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

    【讨论】:

      猜你喜欢
      • 2011-08-26
      • 2018-09-21
      • 2016-06-28
      • 2012-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-30
      • 1970-01-01
      相关资源
      最近更新 更多