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