2

I am running Java code on a remote windows 2012 server. The server will have multiple windows user accounts such as user X, user N, user W and so on.

I want to execute a specific section of code on each account while being logged into Administrator account.

Is it possible to execute a portion of code on another windows user account (i.e, login to account and then log out automatically)?

Note: This is not the same as:

How to get Windows username in Java? - as I already know the name of each account or Creating a Windows user account with java - as I know how to CREATE a new account but I don't know how to automatically login to account and execute code..

Thanks

1 Answer 1

0

Mark,

IBM java community using psexec.exe inside of a java application to perform the action. https://www.ibm.com/developerworks/community/blogs/738b7897-cd38-4f24-9f05-48dd69116837/entry/programmatically_connecting_to_remote_systems2?lang=en is the URL hopefully this helps

 String psCommand = "<path_of_psexec>/psexec.exe \\\\"+currentServerHostname + " -u " + currentServerUser + " -p " + currentServerPass; psCommand = psCommand + " " + commandToRunOnRemoteMachine + " " + parameters; String[] cmd = new String[5]; cmd[0]="cmd.exe"; cmd[1]="/C"; cmd[2]=psCommand; cmd[3]=""; cmd[4]=""; // Run remote command File f = new File(getCurrentWorkingDirectory() + "\\lib"); Process p = Runtime.getRuntime().exec(cmd,null,f); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.