Search code examples
javaruntimeipconfig

Java Runtime.getRuntime().exec("ipconfig/release"); returns error?


I want to disconnect my computer from the internet, and the best way that I can think of, is running the ipconfig/release from the cmd. To do so, I did

 Process result = Runtime.getRuntime().exec("ipconfig/release");

This throws an error however,

java.io.IOException: Cannot run program "ipconfig/release": CreateProcess error=
2, The system cannot find the file specified
        at java.lang.ProcessBuilder.start(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at threadio.run(checkmac.java:141)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find th
e file specified

Which I am not sure what means.

Any ideads what I'm doing wrong? Any better alternatives to disconnect from the router?


Solution

  • It works with a space

    Process result = Runtime.getRuntime().exec("ipconfig /release");