Run command prompt as Administrator

  Runtime.getRuntime().exec("runas /profile /user:Administrator \"cmd.exe /c Powrprof.dll,SetSuspendState\"");

Also plz see comments

Running as admin without Admin rights


You have a few options

A. Create a shortcut with admin priv.

The shortcut will run cmd /c Rundll32.exe Powrprof.dll,SetSuspendState

Your Java code will run the shortcut:

Runtime rt = Runtime.getRuntime();
rt.exec("cmd /c start \"\" \"myshortcut.lnk\"")

Right click the shortcut icon > properties > advanced > run as administrator

B. Run the java process as administrator

Again, create a shortcut and set to run as administrator. Any processes spawned will also have admin privileges. Your java code will run:

rt.exec("cmd /c Powrprof.dll,SetSuspendState")

C. Use JNA to directly call SetSuspendState routine. The Java process will require admin priv (like B), but you won't have to spawn a process. If you like this, I can provide source code.

D. Use wizmo utility: wizmo quiet standby


Add parameter /savecred

runas /profile /user:Administrator /savecred

Input the password one times. In future OS will not ask you password.