cmd command-line parameters to start the program with

cmd command-line parameters to start the program with

       Some programs do not support when it is started directly, when writing code, we can start a process (a software) through the Process class, which initiates a piece of software code that do not tune in, the windows system, usually we will use cmd command line to start. This article will introduce common cmd command-line startup parameters.

1.cmd Help

  Win + R fast running open window, enter cmd determining cmd.exe open procedures.

  cmd help : Open the window, enter cmd: cmd / ?, Enter. You can see the meaning of the corresponding instruction.

2.cmd startup parameters

  Use cmd to start an application, the application to pass parameters:

  The following instructions use indirect cmd under program start ExportBatchTool.exe plate E, and C pass ExportBatchTool .exe program to: \ startup parameter 190627.whd of:

  cmd /C E:\ExportBatchTool.exe C:\190627.whd

  / C after running the program, cmd will be terminated.

  Command: cmd /KE:\ExportBatchTool.exe C: \ 190627.whd will also start the program and pass ExportBatchTool.exe C: \ 190627.whd parameters.

  However, / k after running the program, cmd.exe will still continue to run, so the / c command would be more suitable for automated scripting, and / k command is more suitable for semi-automated script.

  Under Cmd window, direct input: Start E: \ ExportBatchTool.exe C: \ 190708.whd will also start the program and pass ExportBatchTool.exe C: \ 190627.whd parameters.

  START meaning: to start a separate window to run a specified program or command. Enter the help command to view the command Cmd meanings.

3. Notes parameter passing

More than 3.1 parameter passing

  Whether prepared or java program written in C #, which is the entrance of the main program class function, which may receive a [] type of parameter string. Therefore, cmd parameter passing only pass an array of strings. So how to distinguish between array elements? C MD with a space to distinguish .

  In the above example, the spaces not involved in the path, and only one. If there are spaces in the path, then, to avoid this space is used to distinguish elements, including elements of the marks required space (path) due to, represent a whole. But in fact, this time really when you add quotation marks to the path, you will find cmd will not recognize your command path.

  Solution :

  Throughout the passed command cmd layer plus a layer of quotation marks , such as:

  cmd /c " "D:\test flo\test.exe" c:\6283.whd "。

3.2 Special character transfer

  We have a detailed explanation in cmd help. Now part reproduced below, with particular reference to help cmd command to view the special character handling:

  If the string is quoted, you can accept the command separator "&" to separate multiple command.

  Further, for compatibility reasons, / X is as / E: ON, / Y and / E: same OFF, when the / R and / C identical. Any other switches are ignored.

  If you specify / C or / K, the remaining portion of the command will then switch line as a command line process, wherein the following logic process quote ( ") characters:

  1) if all of the following conditions is retained quote characters on the command line:

    - no / S switch;

    - exactly two quote characters;

    - without any special characters, special characters refer to the following characters between the two quote characters: & <> () @ ^ |;

    - At least one space character between the two quote characters;

    - the string between the two quote characters is the name of an executable file.

  2) Otherwise, the old way is to see if the first character is a quote character and if so, remove the first character and remove the last quote on the command line, keep all text after the last quote.

---------

Reference blog post: https://blog.csdn.net/WPwalter/article/details/94128623

Guess you like

Origin www.cnblogs.com/DiKingVue/p/11326359.html
Recommended