I want to turn the firewall in Windows on and off from java code. To do this, I need to execute a cmd command with admin privileges.
I tried this, but it is not running as admin.
public void execute_cmd2() {
Process exec = Runtime.getRuntime().exec("cmd");
OutputStream outputStream = exec.getOutputStream();
InputStream inputStream = exec.getInputStream();
PrintStream printStream = new PrintStream(outputStream);
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream,"utf-8"));
printStream.println("netsh advfirewall set allprofile state off");
//printStream.println("winget uninstall \"voidtools.Everything\"");
printStream.flush();