• Post Reply Bookmark Topic Watch Topic
  • New Topic

Launching an .exe as a different user  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, everyone,

I am wondering if there is any way to launch an .exe from my Java code, specifying a domain\userID and password for the .exe to run under. My Java program runs under the userID that is logged on to the workstation, for example, NWIE\user1. This Java program currently launches an .exe with the following code:

Runtime CHLMONRuntime = Runtime.getRuntime();
try
{
CHLMONProcess = CHLMONRuntime.exec(sClaimsDir +
"cl3chlmon.exe " + iSocket);
}
catch...

The .exe runs under the same userID as the Java code, which is the user that is logged on to the workstation. I would like to modify the Java code to call the cl3chlmon.exe program but instead of having it run under the user who is logged on, specify a local userID called "MQLocal", for it to run under. I haven't found any way to do this in Java.

Any help you can provide would be MOST appreciated!

Thanks,
Leslie
 
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Leslie,

Welcome to JavaRanch!

No, Java doesn't have any way to do this. What you might do would be to execute yet another program, which would then execute your original program on your behalf as another user.

On UNIX there's a standard program "sudo" which can do this. On Windows, I imagine there may be something similar -- you might want to do a Google search or ask on a Windows board.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!