Saturday, 8 February 2014

Windows Command for incoming IP blocking--Java Code

//blocking.... 

Runtime r = Runtime.getRuntime();
Process p = r.exec("netsh advfirewall firewall add rule name=abc action=block remoteip=any dir=in");


//unblocking...

 Runtime r = Runtime.getRuntime();
 Process p = r.exec("netsh advfirewall firewall delete rule name=abc remoteip=any");

//to turn on windows firewall

 Runtime r = Runtime.getRuntime();
 Process p = r.exec("netsh firewall set opmode enable");


//to turn off windows firewall

 Runtime r = Runtime.getRuntime();
 Process p = r.exec("netsh firewall set opmode disable");

1 comment: