我有Apache Ant文件(build.xml),它被设置为创建我的生产服务器的自动备份。它设置为停止Apache服务器& MSSQL2000 - 备份所有内容并再次启动两个服务(及其依赖项)。它在旧的WIN 2008服务器下工作正常,但不在WIN8下。当执行.bat文件运行Ant进程时,它会打开CMD(它应该),但是没有任何停止/启动操作正确执行。我得到“访问被拒绝”。响应。Apache Ant - 启动/停止获取服务 - 访问被拒绝
这是CMD输出时执行.BAT(ANT)的文件:
assemble:
stop.server.apache:
[exec] System error 5 has occurred.
[exec]
[exec] Access is denied.
[exec]
[exec] Result: 2
stop.server.ms-sql:
[exec] No valid response was provided.
[exec] The following services are dependent on the MSSQLSERVER service.
[exec] Stopping the MSSQLSERVER service will also stop these services.
[exec]
[exec] SQLSERVERAGENT
[exec]
[exec] Do you want to continue this operation? (Y/N) [N]:
[exec] Result: -1
[exec] System error 5 has occurred.
[exec]
[exec] Access is denied.
[exec]
[exec] Result: 2
实际的build.xml部负责启动/停止服务如下:
.... ...开头的代码
<macrodef name="service">
<attribute name="service"/>
<attribute name="action"/>
<sequential>
<exec executable="cmd.exe">
<arg line="/c net @{action} '@{service}'"/>
</exec>
</sequential>
</macrodef>
<target name="start.server.ms-sql">
<service action="start" service="MSSQLSERVER"/>
<service action="start" service="SQLSERVERAGENT"/>
</target>
<target name="stop.server.ms-sql">
<service action="stop" service="SQLSERVERAGENT"/>
<service action="stop" service="MSSQLSERVER"/>
</target>
<target name="start.server.apache">
<service action="start" service="Apache2.2"/>
</target>
<target name="stop.server.apache">
<service action="stop" service="Apache2.2"/>
</target>
的.......这里更多的代码
我ALRE ady启用了所有的磁盘/文件夹权限,以确保它没有受到影响(我知道已经有权限从Vista和更改。我还研究了Apache Ant documentation,但我找不到任何有关使用提升权限停止/启动服务的信息。
有什么想法?
注意:Apache2.2和MSSQL从驱动器W:\运行,Win OS从C:运行。我的Ant路径设置正确,但我认为这可能会导致特权访问问题。
谢谢你的回答。第一个建议 - UAC - 我已经设置了最低限度(不通知),第二个 - 我已经尝试过的另一篇文章的链接,我无法完成工作。但我认为你的方向正确事实上,Win8似乎不允许启动这些服务。必须有另一个窗口捕捉到某处。它还能是什么? – Milan