Command cmd should also be used properly

Source: Internet
Author: User
Tags control characters
Previous Program You need to execute some DOS commands, which are generally written as a bat file and then called through Shel. In fact, some simple operations can be used as follows:

VBA. Shell " CMD/c cmd /? > C: \ cmdhelp.txt "
VBA. Shell " CMD/C type C: \ cmdhelp.txt> C: \ copy1.txt "
VBA. Shell " CMD/C copy c: \ cmdhelp.txt c: \ copy2.txt "

The help is as follows:

Start Windows Command to explain a new instance of the program

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.

Note that if the string contains quotation marks, separate them with the '&' command separator.
. In addition, for compatibility reasons,/X and/E: on are the same,/y and
/E: off is the same, and/r is the same as/C. Ignore any other command line switches.

If/C or/K is specified, the rest of the command line after the command line switch will be used as the command line
In this case, the following logic is used to process the quotation mark character ("):

1. If all of the following conditions are met, the quotation marks on the command line will be
Reserved:

-The/s command line switch is not enabled.
-Two full quotation marks
-There are no special characters between the two quotation marks, and the special characters are the following
One: <> () @ ^ |
-There must be at least one blank character between two quotation marks.
-There must be at least one executable file name between two quotation marks.

2. Otherwise, the old method is to check whether the first character is a quote character. If
Yes. Remove the start character and delete the last quote character on the command line,
Retain the text after the last quote character.

If/D is not specified on the command line, it will look
The following REG_SZ/reg_expand_sz registry variables. If one or
Both exist. These two variables are executed first.

HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ command processor \ autorun

And/or

HKEY_CURRENT_USER \ Software \ Microsoft \ command processor \ autorun

Command extension is enabled by default. You can also use/E: off
Disable extensions for specific calls. You can log on to the machine and/or user logon sessions.
Enable or disable all invocation extensions of CMD. EXE.
One or two REG_DWORD values in the registry of regedt. EXE:

HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ command processor \ enableextensions

And/or

HKEY_CURRENT_USER \ Software \ Microsoft \ command processor \ enableextensions

To 0x1 or 0x0. User-specific settings have priority over machine settings. Command Line
The switch has a higher priority than the registry settings.

Command extensions include changes to the following commands and/or addition:

Del or erase
Color
CD or chdir
MD or mkdir
Prompt
Pushd
Popd
Set
Setlocal
Endlocal
If
For
Call
Shift
Goto
Start (including changes made to external command calls)
Assoc
FTYPE

For specific details, type commandname /? View.

Extended delayed environment variables are not enabled by default. You can use/V: On or/V: Off
Enables or disables extended environment variables for a cmd. EXE call.
You can enable or disable cmd. EXE all
Call delay extension, which must be set to use the registry in regedt. exe
One or two REG_DWORD values:

HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ command processor \ delayedexpansion

And/or

HKEY_CURRENT_USER \ Software \ Microsoft \ command processor \ delayedexpansion

To 0x1 or 0x0. User-specific settings have priority over machine settings. Command Line Switch
It has priority over registry settings.

If the extension of the delayed environment variable is enabled, the exclamation point character can be used at the execution time.
Replace the value of an environment variable.

You can use/F: On or/F: off to switch to
The file name is enabled or disabled. You can
The user logs on to the session to enable or disable all cmd. EXE calls,
You can use Regedit. EXE to set the following parameters in the registry:
All or one of REG_DWORD:

HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ command processor \ completionchar
HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ command processor \ pathcompletionchar

And/or

HKEY_CURRENT_USER \ Software \ Microsoft \ command processor \ completionchar
HKEY_CURRENT_USER \ Software \ Microsoft \ command processor \ pathcompletionchar

A hexadecimal value of a control character is used as a specific parameter (for example, 0x4 ).
Is Ctrl-D, 0x6 is Ctrl-f ). User-specific settings take precedence over machine settings.
The command line switch takes precedence over registry settings.

If the/F: On switch is enabled, the following two controllers are used:
Use ctrl-D to complete the directory name and Ctrl-F to complete the file name. To disable
A character in the registry, please use a space (0x20) value, because this character
It is not a control character.

If you type one of the two control characters, the completion is called. After the function is completed
The path string is taken to the left of the cursor. If no wildcard exists, the wildcard is appended.
To the left, and create a list of consistent paths. Then, the first matching path is displayed.
Path. If no matching path exists, a beep will be made without affecting the display. After,
Repeat the same control character to display a list of consistent paths cyclically. Shift
Press the key and control character at the same time to display the list. If you have performed
If you edit the file and press the control character again, the list of saved paths will be
Discard, and the new one will be generated. If you switch between the file and directory name
The same occurs. The only difference between two control characters is the file completion character.
The file and directory names are met, while the directory completion characters only match the directory name. If the file
The directory is used to complete built-in directory commands (Cd, MD, or RD ).
Complete.
Enclose the matching path in quotation marks.CodeCorrect Handling of spaces
Or other special characters. At the same time, if the backup is performed and then called from the row
After the file is completed, the text on the right of the cursor is called.

Special characters that require quotation marks are:
<Space>
& () [] {}^ = ;! '+ ,'~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.