1. Start the Windows Command Interpreter
CMD [/A |/u] [/q] [/d] [/E: On |/E: Off] [/F: On |/F: off] [/V: On |
/V: Off]
[[/S] [/c |/K] string]
/C: Execute the specified string command and then abort
/K executes the specified string command but retains
/S modify string processing after/C or/K (see below)
/Q close echo
/D stop executing the autorun command from the Registry (see below)
/A converts the output to an internal pipeline or file command to ANSI
/U converts the output to an internal pipeline or file command to Unicode
/T: FG sets the foreground/background color (for details, see color /?)
/E: Enable command extension on (see below)
/E: off stop command extension (see below)
/F: Enable file and directory name completion characters on (see below)
/F: off stop file and directory name completion characters (see below)
/V: On! Start and delay environment variable extension as a separator. For example,/V: On will
Yes! VaR! Allowed during execution! VaR! Extension variable VAR. VaR syntax
Variable extension during input, which is different from in a for loop.
/V: Off disables latency environment extension.
2. Call command line parameters in Java
Java runtime.getruntime(cmd.exe C (commandstr) can call and execute the CMD command.
CMD/C dir: Close the command window after executing the Dir command.
CMD/K dir does not close the command window after executing the Dir command.
CMD/C start dir opens a new window and executes the Dir command. The original window is closed.
CMD/K start dir will open a new window and execute the Dir command. The original window will not close.
3. Example
Shell ("command.com/C [command]", [windowstyle])
1. Execute the BAT file
Shell "batname"
2. Execute the Java EXE file
Shell ("exename", 1)
3. Execute a Java File
Shell "Java myjavaclass"
4. Open a file
Shell "CMD/c cmd /? > C:/cmdhelp.txt"
5. Clear files in cookies
Shell "C:/window/system32/cmd.exe/C del" "C:/cmdenmts and settings/my family/cookies/*. txt """,
6. Execute the EXE execution File
Shell "notepad.exe D:/ping.txt"