Executing system commands from under Java (Runtime. exec)

I need an explanation of the syntax of "system commands" for the exec method parameter().

Runtime.getRuntime().exec("cmd /c start cmd.exe");

What, for example, in this case means the meta character \c and the parameter start. It is clear that it starts the command line, but why not just cmd.exe? After all, some processes are launched just along the way. Where can I find a complete syntax guide? The Oracle documentation is silent about this...

In advance thanks)

Author: Dev0ps, 2019-02-21

1 answers

These are the windows console commands (click Start-run-type "cmd") that the java virtual machine runs via Runtime. getRuntime (). exec (...).

Runtime.getRuntime().exec("cmd /c start cmd.exe");

With this combination of commands, a separate cmd window is launched.

Cmd-command interpreter

Start-command to start something in a separate window

C:\Windows\System32>cmd /?
Запуск новой копии интерпретатора команд Windows.

CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF]
    [[/S] [/C | /K] строка]

/C      Выполнение указанной команды (строки) с последующим завершением.

In fact, we do this:

  1. Run the cmd interpreter

  2. Run the start command in it, which opens a separate cmd window

  3. Shut down cmd

P.S. If it was assumed that a java program should be executed not in Windows, but for example in Linux, then the commands would be different.

 1
Author: virex-84, 2019-02-22 02:34:28