Elevate(Run as Administrator) Command prompt in Ant task

In Ant task we can use exec task to run any executable file.Like that we can also use command prompt with exec task
<property name=”admincmd” value=”./elevate.cmd” />
<property name=”server.location” location=”c:/Apache/tomcat/bin” />
<exec executable=”${admincmd}” failonerror=”false”>
<arg value=”cmd” />
<arg value=”/k” />
<arg value=”${server.location}/service” />
<arg value=”install” />
</exec>
In the above code snippet elevate.cmd source can be downloaded from here
to run this code correctly we need to put the two files elevate.vbs, elevate.cmd in the same directory and  should be available in appropriate location which is define in the property admincmd.

If any Doubts and Clarifications feel free to Contact  @ sk.baji6@gmail.com


Post a Comment

Previous Post Next Post