Search code examples
antwindows-server-2008-r2runas

"Runas" in Ant script


I have an application which needs to run with different user name.

I am trying to call "runas.exe" to call the batch file which calls my application.

When I tried this in command prompt it worked fine. One drawback is I have to provide password

I am wondering if this is possible as this runs on build sever without anyone intervention

Here http://blogs.msdn.com/b/oldnewthing/archive/2004/11/29/271551.aspx Microsoft explains why we cannot give password as command line parameter

I don't know what could be the better approach. Can anyone suggest any good alternative

I use Windows 2008 R2 64 bit


Solution

  • You can't do this, unless you write a small program which does this for you. Batch won't cut it for obvious security reasons.

    A sample program that will work in windows xp can be found here.