使用apache-ant到IIS配置运行OS命令 [英] Running an OS command using apache-ant to IIS config
本文介绍了使用apache-ant到IIS配置运行OS命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建一个ANT脚本,该脚本除其他外将配置IIS.
为此,请尝试利用appcmd
工具.但是得到一个奇怪的错误. appcmd
命令在ant脚本外部运行良好,但在ant脚本内部运行失败.
I'm trying to create an ANT script which amongst other things will configure IIS.
To do this, trying to harness the appcmd
tool. However getting a strange error. The appcmd
command runs fine outside of the ant script, but fails within.
我正在使用exec任务将其全部启动:
I'm using the exec task to kick it all off :
<exec dir="C:\\Windows\\System32\\inetsrv\\"
executable="C:\\Windows\\System32\\inetsrv\\appcmd.exe" output="d:\out.txt">
<arg value="appcmd set config /section:isapiCgiRestriction /+"
[path='${appian_home}\\jakarta\\ISAPI\\isapi_redirect.dll',
description='Jakarta',allowed='True']"" />
</exec>
通过ANT捕获的输出为:
The output trapped via ANT is :
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.
但是当我跑步时 如果我在dos提示符下键入该命令,它将很高兴地运行:
However when I run If I c&p that command to the dos prompt it will happily run :
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"
推荐答案
也需要转义单引号.
还将路径更改为/
在下面使用:
<exec executable="cmd.exe" dir="C:/Windows/System32/inetsrv" failonerror="true">
<arg line="/c appcmd set config /section:isapiCgiRestriction /+"[path='${appian_home}/jakarta/ISAPI/isapi_redirect.dll',description='Jakarta',allowed='True']""/>
</exec>
这篇关于使用apache-ant到IIS配置运行OS命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文