有没有办法让 ANT 任务在 Windows Vista 中以管理员身份运行? [英] Is there a way to make an ANT task run as Administrator in Windows Vista?

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

问题描述

作为安装程序的一部分,我需要从 ANT 运行批处理文件.如果我以管理员身份运行 cmd.exe 并运行批处理文件,则一切正常,因为它具有适当的管理权限.当从 ant 执行批处理文件时,它会失败,就像我在没有管理权限的情况下运行批处理文件一样.我的问题是,如何从我的 ANT 脚本以管理模式运行这个批处理文件?

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>

推荐答案

关闭 UAC 似乎是允许此 ant 任务执行的唯一选项.

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]

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

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