Java runs CMD command simple code for Windows

  • 2020-04-01 02:38:26
  • OfStack

I don't know what this is called, but if I want to open my computer's computer, I can just type "calc" on the command line.
Now let the code execute.


public static void main(String[] args) throws IOException {  
        Runtime.getRuntime().exec("calc");  
    }  

The results are as follows:

< img border = 0 SRC = "/ / files.jb51.net/file_images/article/201312/20131226160525219.png" >

Because it is the campus network, usually like to sleep when the 360wifi plug in the computer open wifi, and then go to bed to play mobile phone, finished do not want to get up and turn off the computer, so I wrote a small program to turn off the computer. That's the principle.


Related articles: