有没有一种方法,使在Windows Vista中以管理员身份运行一个Ant任务? [英] Is there a way to make an ANT task run as Administrator in Windows Vista?

查看:295
本文介绍了有没有一种方法,使在Windows Vista中以管理员身份运行一个Ant任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为安装程序的一部分,我需要运行ANT的批处理文件。如果我运行cmd.exe的管理员和运行批处理文件,一切都很好,因为它具有相应管理权限。当该批处理文件是从蚂蚁,它失败了,以同样的方式执行它,如果我要运行该批处理文件,而无需管理权限。我的问题是,我该如何从我的运行Ant脚本中以管理模式这个批处理文件?

 < EXEC可执行=cmd.exe的产量DIR.TXTDIR =C:/斌/>
< ARG行=/ C service.bat安装/>
< / EXEC>


解决方案

关闭UAC似乎是允许该Ant任务执行的唯一选择。

我试图使一个快捷方式到批处理文件,并运行,由于快捷键可设置为以管理员身份运行。没有运气无论是作为我得到的提示,但我的批处理文件仍然失败了。

[<一个href=\"http://www.mydigitallife.info/2007/02/17/how-to-open-elevated-command-prompt-with-administrator-privileges-in-windows-vista/\" rel=\"nofollow\">http://www.mydigitallife.info/2007/02/17/how-to-open-elevated-command-prompt-with-administrator-privileges-in-windows-vista/][1]

As part of an installer, I need to run a batch file from ANT. If I run cmd.exe as Administrator and run the batch file, all is well since it has the appropriate administrative privileges. When the batch file is executed from ant, it fails, the same way it does if I were to run the batch file without administrative privileges. My question is, how can I run this batch file in Administrative mode from my ANT script?

<exec executable="cmd.exe" output="dir.txt" dir="c:/bin/">
<arg line="/c service.bat install"/>
</exec>

解决方案

Turning off UAC seems to be the only option to allow this ant task to execute.

I tried making a shortcut to the batch file, and running that, since shortcuts can be set to 'run as administrator'. No luck there either as I get the prompt, but my batch file still fails out.

[http://www.mydigitallife.info/2007/02/17/how-to-open-elevated-command-prompt-with-administrator-privileges-in-windows-vista/][1]

这篇关于有没有一种方法,使在Windows Vista中以管理员身份运行一个Ant任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆