1

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;
}

}

sam
  • 38
  • 4
  • you can refer this answer on [https://stackoverflow.com/questions/27332003/how-do-i-request-uac-administrative-privileges-with-a-javafx-desktop-application/44564485#44564485](https://stackoverflow.com/questions/27332003/how-do-i-request-uac-administrative-privileges-with-a-javafx-desktop-application/44564485#44564485) – X zheng Jun 15 '17 at 10:18

1 Answers1

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>  
X zheng
  • 1,731
  • 1
  • 17
  • 25