Hello Guys i am going to run java program on window as administrator. How i can do this ? I tired this https://github.com/rritoch/super-user-application but it only has self class. I don't like this. What is the best solution for java run as administrator. Thank you!
package com.vnetpublishing.java;
import com.vnetpublishing.java.suapp.SU;
import com.vnetpublishing.java.suapp.SuperUserApplication;
public class TestAdmin extends SuperUserApplication {
public static void main(String[] args) {
SU.run(new TestAdmin(), args);
}
public int run(String[] args) {
System.out.println("RUN AS ADMIN! YAY!");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return 0;
}
}
答案 0 :(得分:1)
please use lanuch4j and add manifest file you can use follow code.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="highestAvailable" uiAccess="False" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>