Effective console. SETLOCAL command - changing the variables for a stream command file

    Team SETLOCAL The value of time changes in commands is discussed for the time change Windows files. Changes to the middle, made after executing the SETLOCAL command, locally to the stream batch file. To update existing values, you must exit the ENDLOCAL command. When the end of the batch file is reached, the ENDLOCAL command is automatically ended for all other SETLOCAL commands added to the batch file, and the values ​​of all changes are updated until the end of the SETLOCAL command.

Team Row Format:

SETLOCAL | ENABLEDELAYEDEXPANSION | DISABLEDELAYEDEXPANSION

Changing the SETLOCAL command when extended command processing is enabled:

The SETLOCAL command accepts optional arguments: ENABLEEXTENSIONS and DISABLEEXTENSIONS. This allows you to embed or embed an extended processing of commands up to the next command. Div CMD /? report explanation. ENABLEDELAYEDEXPANSION / DISABLEDELAYEDEXPANSION enables or disables the expansion of the exchangeable middle. SET /? report explanation. These changes continue until the ENDLOCAL command is executed, regardless of the output until the SETLOCAL command is called.

If the SETLOCAL command is followed by an argument, it will insert the ERRORLEVEL reset code. When one of two valid arguments is specified, the break code is set to zero, otherwise the value is set to 1. This power can be modified in batch files to indicate the availability of extended command processing, for example:

VERIFY OTHER 2>nul
SETLOCAL ENABLEEXTENSIONS
IF ERRORLEVEL 1 echo It is impossible to insert an extended function

This group of commands works because in earlier versions of CMD.EXE the SETLOCAL command does not set the ERRORLEVEL value. A VERIFY command with an invalid argument is required to set a non-zero ERRORLEVEL value.

When changes are made to the command files, the main line of demarcation is due to the fact that the meaning is lost without change when modified in the middle of a group of commands, which is specified by arcs, for example in commands IF or else FOR. To bypass this exchange, the command processor is launched with the /V:ON parameter and the substitution of the symbols is performed; to remove the variable value, the symbols are substituted. In addition, there is a clear possibility of vikoryism standard launch command processor, ale z local inclusions given to the mode with the command:

The difference in the results of the different values ​​of the variables is clearly demonstrated by the following command file:


@ECHO OFF
set VAR=before
if "%VAR%" == "before" (
set VAR=after
if "!VAR!" == "after" @echo Zi percent sign=%VAR% , Zi nutrition sign=!VAR!

Team set VAR=after is located in the middle of the subprogram, surrounded by bows, to receive the command Setlocal EnableDelayedExpansion or else don’t use it to remove the value of the change VAR hail signs, which means losing the old ones (those that were installed before entering the subprogram). A similar problem occurs if the variable value is changed in the middle of a command cycle FOR. For example, to display a list of files in a stream directory, such a command file is not suitable:

set LIST=
for %%i in (*) do set LIST=%LIST% %%i
echo %LIST%

Meaning of change LIST mid-cycle will not be changed. If so, you need to change the command file like this:

Setlocal EnableDelayedExpansion
set LIST=
for %%i in (*) do set LIST=!LIST! %%i
echo %LIST%
Now, the meaning of the change LIST in the middle of the cycle FOR will change, sequentially taking on the meaning of file names separated by a space ( set LIST=!LIST! %%i)

Another way to correct the IF command is to check the origin of the specified file. The syntax for this is as follows:

IF EXIST file command1

The mind respects the truth, because instructions file I'm sleeping. The file name is not required. Let's look at the command file, which, using this option of the IF command, checks the presence of the file specified as a command line parameter.

@ECHO OFF IF -%1==- GOTO NoFileSpecified IF NOT EXIST %1 GOTO FileNotExist REM File Found Notification ECHO File "%1" was successfully found. GOTO:EOF:NoFileSpecified REM Launch file without ECHO The command line does not have a file name specified. GOTO:EOF:FileNotExist REM Command line parameter of tasks, but file not found ECHO File "%1" not found.

Verification of the presence of a changeable substance

Similar to files, the IF command allows you to check whether the system has a variable fluid:

IF DEFINED change command1

Here the DEFINED mind is set to the same as the mind EXISTS of the specified file, but it takes the name of the changeable middle as an argument and rotates the reference value if the change is specified. For example:

@ECHO OFF CLS IF DEFINED MyVar GOTO:VarExists ECHO MyVar is not defined GOTO:EOF:VarExists ECHO MyVar is defined, ECHO MyVar is different %MyVar%

Checking the completion code of the previous command

Another way to revise an IF command is to check the completion code (exit code) of the preceding command. The syntax for IF looks like this:

IF ERRORLEVEL number command1

Here the truth is true, since the command was still running or the program ended with the return code, which is the same as the specified number.

For example, there is a command file that copies the my.txt file to drive C: without displaying on the screen a notification about the copying, and at any time there will be some kind of compensation seen in advance:

@ECHO OFF XCOPY my.txt C:\ > NUL REM Checking the copy completion code IF ERRORLEVEL 1 GOTO ErrOccurred ECHO Copying in Vikon without any pardons. GOTO:EOF:ErrOccurred ECHO When the XCOPY team was killed, there was a mess!

In the IF ERRORLEVEL... operator, you can also use operators for equalizing numbers, as shown in the table. 3.2. For example:

IF ERRORLEVEL LEQ ​​1 GOTO Case1

Respect.

Another useful way to work with program termination codes is to change %ERRORLEVEL% . (line-by-line representation of the ERRORLEVEL execution code).

Checking the implementation version of extended command processing

Decide that to determine the internal version number of the threaded implementation of extended command processing, the IF statement will be set to this form:

IF CMDEXTVERSION number command1

Here the mind of CMDEXTVERSION is similar to the mind of ERRORLEVEL , and the number is equal to the known internal version number. The first version is number 1. The version number will increase by one if advanced command processing options are added. Since the processing of commands is expanded, the mind of CMDEXTVERSION is never true.

Organization of cycles

In command files for organizing loops, there are a number of different types of the FOR operator that provide the following functions:

  • the specified command for all elements of the specified multiplicity;
  • the specified command for all types of file names;
  • Confirming the specified command for all types of directory names;
  • The specified command for the first directory, as well as all its subdirectories;
  • separating the sequence of numbers from the given beginning, end and increase;
  • reading and processing rows from a text file;
  • processing of rows of song command output
Loop FOR...IN...DO...

The simplest version of the FOR command syntax for command files looks like this:

FOR %% variable IN (multiple) DO command [parameters]

Uvaga

Before the name of honor there are two symbols (%%) and not one, as was the case when the command FOR was removed from the command line.

Let’s straight away point the butt. How the command file has rows

@ECHO OFF FOR %%i IN (One, Two, Three) DO ECHO %%i

then, as a result of your display, the following will appear on the screen:

One two Three

The nameless parameter of the FOR command specifies one or more text rows, separated by lines, that you want to process for a given command. The arms here are obov'yazkov. Parameter command [options] specifies a command assigned to each element of the multiplicity; nesting of FOR commands in one row is not allowed. If there is a coma in a row that goes up to a multiplicity, then a significant row needs to be placed in the paws. For example, as a result of vikonnaya file with commands

@ECHO OFF FOR %%i IN ("One, Two", Three) DO ECHO %%i

will be displayed on the screen

One two Three

The %% variable parameter represents the variable that is being submitted (the treatment to the cycle), and only the names of the variable that are formed from the same letters can be changed here. When vyconann, the FOR command replaces the variable that is being substituted with the text of the skin row in the given multiplicity, until the command that comes after keyword DO does not process all such rows.

Miscenahodzhennya: Windows\system32

Description: Windows Command Processor

In Windows XP this is the name of the console - program cmd.exe as a command interpreter. When launched simply, without specifying command line parameters, the console displays the version of the operating system, information about copyright protection of OS vendors and the same command line, in which you can enter as a command line parameter of the program itself cmd.exe, and be it an external command, for example, a command to launch another application, or a standard command such as mkdir, del, etc.

Command Row Options

The syntax for the command line is:

CMD[team]

You can vikorize a number of teams at a time, vikorist, and between them there is a special separator - the symbols &&, in which all the data from a number of teams can be placed in the tabs, for example, " team&&team&& team".

/? - vyklik dovidki

/A- Result of the results of a given command in ANSI format

/C- Vikonannya given command with the upcoming closure of the console window

/D- enabling the selection of AutoRun commands (which are the first to be automatically selected when you click cmd.exe), specified in special sections of the registry HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun і HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun

/E:ON (/E:OFF)- Added (protection) the expansion of commands. In Windows XP, the processing of all cmd.exe commands has been expanded, this parameter is used to enhance/extend the expansion of a specific process. The extended processing includes the following commands: assoc, call, chdir (cd), color, del (erase), endlocal, for, ftype, goto, if, mkdir (md), popd, prompt, pushd, set, setlocal, shift, start(Clicks for external teams have also been changed)

/F:ON (/F:OFF)- allowed (protected) the completion of file names and folders (protected) to a specific command cmd.exe. Add a manual function that allows you not to manually enter the name of files or folder names in the console window, but to enter only part of the name by pressing a special combination of date keys operating system Find out the available options and simply select the one you need. (If you need to enable or disable name completion for all calls cmd.exe, then be amazed Automatic command dialing).

Computer settings take precedence over computer settings, and the command processor /F value takes precedence over registry options. Microsoft has clarified the value of this function: "If completion is specified using the command line switch / F:ON, then two control characters are used: Ctrl+D for folder names and Ctrl+F for file names.

To insert a specific termination character into the registry as a code special symbol vikorist sixteenth value space symbol (0 x 20). Completion is indicated when one of these special characters is entered. The completion function takes a row of paths left-handed from the insertion point, adds a symbol to the pattern before it, such as a day, and then there will be a list of paths that correspond to the selected value.

After this, the first element in the list of distinguished routes is displayed. If the list is empty, then it is submitted beep and nothing will be displayed. After this repeated introduction of that same special symbol, a cyclic search of all types of paths is carried out.

Pressing the Shift key while typing the keruvannya symbol allows you to look through the list of routes in reverse order. If you change the entry of routes, and then enter the symbol again, the savings list is cleared, and a new list of routes will be created. The same is true when switching from one completion symbol to another.

The same difference when the file termination symbol is vicarious lies in the fact that when creating an access list, both the paths and the file name are taken, and when the folder termination symbol is vicarious, only the paths are taken. If the completion symbol appears in one of the issued folder manipulation commands (CD, MD or RD), the folder completion symbol is always respected. The completion symbol works correctly with file names to replace spaces or other special characters, such as the order of type of placement at the foot.

In addition, if you move the insertion point to the left, and then insert the completion symbol in the middle of the row, the text that loses the right hand from the insertion point will be thrown out. Special symbols that force the skin into the paws:<пробел>&()()^=;!"+,~". Has everything cleared up?

/K- Exit the specified command without further completion (the console window will not close)

/Q- Vimknennya displaying commands on the screen (ECHO OFF). /R - similar to the /C parameter

/S- Change the behavior of the command after /C or /K

/T: color - set the color of the text and background of the console window. The color parameter has the value of two sixteenth numbers: the first indicates the color of the background of the window, and the other - the text of the window. Then the result of the victory of the command "CMD/T: 7C" will be light red letters on a white aphid.

/U- Result of the results of the command in the Unicode format

/V:ON (/V:OFF)- allowed (fence) the added expansion of the changeable middle (for a specific cmd.exe click) from zastosuvanny hail sign"!" like a separator. For example, /V:ON allows vikorystuvat!var! as an expansion of the change var under the hour of conquest. The var syntax serves to expand the changes made when entered to produce different results in the middle of a FOR loop. When the expanded middle is closed, the symbol "!" (a sign of a hail) can be used to replace the flow value of the replacement medium at the hour of the Vikonanne; /X - means the same thing as the key /E:ON, from the darkness of the value; /Y the same as i /E:OFF. And a little more respect.

If the keys /C or /K are specified, then the command row after such a key is formed as a command row, and the processing of the paw symbols (") is carried out in this manner. The paw symbols in the command row are saved, since all steps of the mind are entered: the /S key is missing, There are exactly two paw symbols, between them there are no other special symbols, such as: &<>()@^|; between them there is one or a few clearings; row, placed in the paws, in the names of the file to be finished. In the other case, the first character is checked, and if it is a paw symbol, it is removed, the remaining paw symbol in the command line is also removed, and all the text of the last paw symbol is saved.

Table for setting the color of the text and background of the console window:

0 – black; 1 – blue; 2 – green; 3 – blakitnium; 4 – chervony; 5 - violet; 6 – zhovtiy; 7 – white; 8 – series; 9 - light blue; A – light green; B – light blue; C – light red; D – light lilac; E – light yellow; F – bright white.

Before speaking, the color and other settings can be changed in another way. Click right button Move along the window title row and select Power. You will see a number of tabs where options for changing programs will be available. If you do not like the standard black screen of the command row, then on the Color tab you are prompted to select a color for the screen and text or from 16 standard colors, for which there are similar characters, or by specifying a numerical value for the color RGB format. On the Layout tab you can adjust the size of the window and screen buffer. Like in early MS-DOS operating systems and Windows size The screen was deprived of the same 25 rows in height and 80 characters in depth, and to display a large number of rows it was necessary to add the |more command, then in NT and later systems you can simply set a large buffer size to the screen and core feel the dark scrolling, which is richer.

Text in the command row window To copy and paste text in the command row window, key combinations native to Windows, such as Ctrl+C, Ctrl+V, will not be used. To remove text from the clipboard, you will have to click the menu, right-click on the window title, and select the Edit submenu. Or just right-click on the window. To copy text from the window, select Mark and use your mouse to see the required text. Then either press the Enter key, or select Copy in the same menu. If you need to paste text in the command row window, go to the Paste command. To re-visit a command, use the arrow keys<<вверх>> і<<вниз >>, which allows you to navigate through the list of commands. To clear the screen, the cls directive is used in the text.

TITLE- to change the row header

TITLE[Row], row - this is the current title of the command row window (recorded without tabs). Once you have entered the title of the window, you can change it by simply clicking the TITLE command again. These commands may appear in the command files.

So, with the butt pointed lower, it will be accompanied by the appearance of a noticeable write in the title of the window:

TITLE Files are being copied...

COPY \\Server\Share\*.doc C:\User\Common\*.doc

ECHO Copying completed.

TITLE Process completed

Team AT- For additional commands, you can run commands and programs at the earliest hour.

AT[\\computer] [ | /DELETE ]

AT[\\computer] time [ /EVERY:date[,...] | /NEXT:date [,...]] "command"

\\ Computer name instructs on remote computer, on which planned tasks can be launched. If this parameter is not specified, then the computer is transferred, on which the AT command is launched;

id identifier of the assigned command;

/delete Executes the intended command. If ID is omitted, all command values ​​on the computer are skipped;

/yes This parameter, when the previous parameter is selected (/delete), automatically turns on confirmation for all requests;

time hour of command (in the 24-year format Godini:khvilini);

/interactive Allows the AT command to communicate with connections up to Narazi in the system of koristuvachami;

/every:date[,...] selects the command for each day (days) of the year and month. If the date is omitted, the exact day of the month is taken into account;

/next:date[...] The entered command will be executed when the specified date arrives (for example, the coming Thursday). If the date is not specified, the exact day of the month is taken into account;

"team" vouch for Windows command NT or package program, yak will be vikonan. The file name may be entered in full. In this case, how does it depend on internal commands, for example, COPY or DIR, and not vikonuvany file, then it is necessary to launch the command interpreter with the /C switch, for example:

AT 10:00 CMD / C DIR > C:\test.out.

Team For- These possibilities are great, but we are limited to demonstrating just one of them - Copying at least to all machines at once. It is possible that you need to copy the file to twenty machines. It's really hard to fight. Initially, the list.txt file records a list of all available machines. The console says:

net view > c:\list.txt

Then, to delete, for example, copy the patch.exe file to a machine in the list, we issue the command:

FOR /F "tokens=1" %i in (z:\list.txt) to copy d:\temp\patch.exe "%i\C$\program files\ICQ"

The change %i will automatically accept the NetBIOS machine name values ​​from a new row in the list.txt file and will be copied to that machine.

Change in view of the request of the command line

cmstp.exe

Miscenahodzhennya: WINDOWS\system32

Description: Microsoft Connection Manager Profile Installer

Install or view the connection manager service profile. Vikonana without parameters command cmstp installs a service profile with standard parameters that correspond to the operating system and the user's permissions.

comp.exe

Miscenahodzhennya: WINDOWS\system32

Description: File Compare Utility

Byte-by-byte alignment of two or more files. Team comp allows you to revise files that are located on different disks and in various catalogues. When updating files, use additional commands comp Their names are displayed and their names are displayed. Vikonana without parameters command comp requests files for updating.

Description of the program in Dovidtsa Windows

Syntax:

comp[file1] [file2] [ /d] [/a] [/l] [/n= number_rows] [ /c]

To change the directory C:\Reports from the backup directory \\Sales\Backup\April , enter the following command:

comp c:\reports\sales\backup\april

To align the first ten rows of files in the \Invoice catalog and display the result in tens format, enter the following command:

comp \invoice\*.txt \invoice\backup\*.txt /n=10 /d

compact.exe

Miscenahodzhennya: WINDOWS\system32

Description: File Compress Utility

Displaying information or changing hardened files and directories in NTFS partitions. Command launched without parameters compact display information about the expansion of files in the streaming catalog.

Description of the program in Dovidtsa Windows

Syntax:

compact[(/c|/u)] ] [file_name[...]]

control.exe

Miscenahodzhennya: Windows\system32

Description: Panel Windows management - Windows Control Panel

This command is used to launch applets. Panels.

Poradi: How to automate login to the system

Registry: Preventing the launch of Control Panels and applets

convert.exe

Miscenahodzhennya: Windows\system32

Description: File System Conversion Utility

The command line utility is used to recreate volumes file system FAT and FAT32 with the NTFS file system.

Syntax:

convert[to] /fs:ntfs

cscript.exe

Miscenahodzhennya: Windows\system32

Description: Microsoft (r) Console Based Script Host

Script server cscript.exeє console version, used for interacting with the client through the command line (to be administrated under GUI programs wscript.exe).

Syntax:

cscript[script_name] [server_parameters] [script_arguments]

Description of parameters available in Windows

cacls.exe

Miscenahodzhennya: Windows\system32

Description: Change the access table - Control ACLs Program

The program is used to view or change the files of the selected database access table (DACL).

Description of programs available in Windows

In Windows XP, the cmd.exe command interpreter, when simply launched, without specifying command line parameters, displays the version of the operating system, information about copyright protection of OS vendors, and also the command line itself, in which you can enter a command line parameter of the program itself mi cmd. exe, or an external command, for example, a command to launch another program, or a standard command such as mkdir, del, etc. Once you enter the parameters of the command line, you will, of course, remove the actions additional possibilities. The syntax is like this:

CMD [command]

Here the command, which is in power, specifies a command or program to be completed. You can select a number of commands at the same time, selecting them, and between them there is a special separator - the symbols &&, in which all the entries of a number of commands can be placed in tabs, for example, “command&&command&&command”.

Now the Mayzhe is the OFITSIAN Documentary Microsoft (I took the smile of the ї Pіdredaguvati, having shifted the trochi for the people, Yaksho Ts in the Danas Vipad, I can handle the Rodchifruvati of the skin parameter:

/?

Viklik dovidki (even a report, on the basis of this article, this article was written).

/A

Displays the results of the specified command in ANSI format.

/C

Saves the given command as soon as it is completed (this will close the console window).

/D

Windowing of AutoRun commands (which are the first to automatically open when you click cmd.exe), tasks in special sections of the registry (in which section parameters of the REG_SZ type are set) and (in which section parameters of the REG_EXPAND_SZ type are set).

/E:ON (/E:OFF)

Allowed (fence) expansion of teams. In Windows XP, the processing of all cmd.exe commands has been expanded, this parameter is used to enhance/extend the expansion of a specific process.

Enable completely or enable advanced processing on this computer or for a specific customer it is possible in the registry, in the following sections and.

The parameter "EnableExtensions"=dword:00000001 in these sections enables extensions, and "EnableExtensions"=dword:00000000 - enables, in which the user parameters have priority over the computer parameters, the value of the /E parameter of the command processor has priority over the parameters registry.

When expanding the processing of commands, changing and/or adding additional commands will be interrupted: assoc, call, chdir (cd), color, del (erase), endlocal, for, ftype, goto, if, mkdir (md), popd, prompt, pushd, set, setlocal, shift, start (the input of external commands is also changed); /F:ON (/F:OFF) - allow (disable) completion of file and folder names (disabled) for a specific cmd.exe command. Add a manual function that allows you not to manually enter the file or folder names in the console window, but enter only part of the name by pressing a special combination of date keys of the operating system Find out the available options and simply select the one you need.

If you need to enable or disable name completion for all cmd.exe calls, then in the registry sections (for the local machine) and (for the in-line machine) set the following parameters (the values ​​are indicated for the settings):

"CompletionChar"=dword:00000040
"PathCompletionChar"=dword:00000040

in such a way that their hexadecimal values ​​correspond to the character code that performs a specific function (for example, 0 x 4 for Ctrl+D or 0 x 6 for Ctrl+F). This allows you to create a utility at home, which has been invented and described more than once in our magazine, TweakUI.

Computer settings take precedence over computer settings, and the command processor /F value takes precedence over registry options.

Microsoft has clarified the value of the function: "If completion is enabled via the additional command line switch /F:ON, then two key characters are selected: Ctrl+D for folder names and Ctrl+F for file names. To include a specific character completeness c As part of the special character code, the sixteenth value of the space character (0 x 20) is entered. Completion is indicated when one of these two special characters is entered.

The completion function takes a row of paths left-handed from the insertion point, adds a symbol to the pattern before it, such as a day, and then there will be a list of paths that correspond to the selected value. After this, the first element in the list of distinguished routes is displayed. If the list is empty, a beep will sound and nothing will be displayed. After this repeated introduction of that same special symbol, a cyclic search of all types of paths is carried out.

Pressing the Shift key while typing the keruvannya symbol allows you to look through the list of routes in reverse order. If you change the entry of routes, and then enter the symbol again, the savings list is cleared, and a new list of routes will be created. The same is true when switching from one completion symbol to another. The same difference when the file termination symbol is vicarious lies in the fact that when creating an access list, both the paths and the file name are taken, and when the folder termination symbol is vicarious, only the paths are taken.

If the completion symbol appears in one of the issued folder manipulation commands (CD, MD or RD), the folder completion symbol is always respected.

The completion symbol works correctly with file names to replace spaces or other special characters, such as the order of type of placement at the foot. In addition, if you move the insertion point to the left, and then insert the completion symbol in the middle of the row, the text that loses the right hand from the insertion point will be thrown out.

Special symbols that force the skin into the paws:

<пробел> & () { } ^ = ; ! ’ + , ` ~ "

Has everything cleared up?

/K

Exit the specified command without further completion (here the console window will not close).

/Q

Vimknennya displaying commands on the screen (ECHO OFF).

/R

Similar parameter /C.

/S

Change the behavior of the command after /C chi /K.

/T:color

Specify the color of the text and the background of the console window.

The color parameter represents the appearance of two sixteenth numbers: the first determines the color of the background of the window, and the other of the text of the window. If the set of colors was not changed at the time cmd.exe was launched (for example, by another session of the command processor), then the registry parameter that means external look consoles:

"DefaultColor"=dword:00000000

The types of these color numbers are shown in the table.

Then the result of the execution of the command “CMD / T: 7C” will be light red letters on a white aphid.

/U

Displaying the results of the command in Unicode format.

/V:ON (/V:OFF)

Allowed (fence) the added expansion of the variable middle (for a specific call cmd.exe) from the stop sign of the call "!" like a separator. For example, /V:ON allows vikorystuvat!var! as an expansion of the change var under the hour of conquest. The var syntax serves to expand the changes made when entered to produce different results in the middle of a FOR loop.

Also, the expanded variable middleware can be added or added to the registry, sections (for a local machine), (for an in-line machine), by setting the parameter "DelayedExpansion"=dword:00000001 for the permission "DelayedExpansion"=dword:0000000 0 for fence.

The computer settings have priority over the computer settings, the /V value of the command processor has priority over the registry parameters.

When the expanded middle is closed, the symbol "!" (the symbol is a sign of a hail) can be used to replace the flow value of a changeable medium under the hour of vicination.

/X

Means the same thing as the key / E: ON, from the darkness of the meaning.

/Y

The same ones that i /E:OFF.

And finally, a lot of valuable respect.

If the keys /C or /K are specified, then the command row after such a key is formed as a command row, and the processing of the paw symbols (") is carried out in this manner. The paw symbols in the command row are saved, as all steps of the mind are completed:

  • key /S day;
  • є exactly two paw symbols;
  • There are no other special characters between them, such as: &< > () @ ^ |;
  • between them there is one or a few clearings;
  • row, placed in the paws, in the names of the file to be finished.

In the other case, the first character is checked, and if it is a paw symbol, it is removed, the remaining paw symbol in the command line is also removed, and all the text of the last paw symbol is saved.

Videdennya, zavdannya and vidennya vidennya zmіnnykh sredovishche cmd.exe.

SET [change=[row]]

Zminna Im'ya zminnogo middle.

Row The row of symbols that is assigned to the specified variable.

Enter SET without parameters to display the exact changeable media.

Changing the SET command when extended command processing is enabled:

If, at the hour of the call, indicate the name of the change without a sign of equality and meaning,

The SET command will display the values ​​of all the variables whose names begin

From the designated row. For example:

This command will display the meaning of all variables whose names begin with "P".

If the name of the change is not found in the flow medium, when the SET command is turned

insert the reset value ERRORLEVEL 1.

The SET command does not allow the equalizer in the name

vile middling.

The SET command supports two additional keys:

SET /A viraz

SET / P variable =

The /A key indicates that the right-hand row in the sign of equality is numeric

Viraz, the meaning of which is calculated. Collection of Viruses

simple and supports the same operations listed in the order of descent

priority:

() - grouping

! ~ - - unary operators

*/% - arithmetic operators

Arithmetic operators

<< >> - two-wheel drive

& - double I

^ - Dviykove vyklyuchne ABO

| - Dviykove ABO

= *= /= %= += -= - assigned

&= ^= |= <<= >>=

Rozdіlyuvach operators

When selecting any logical or dyadic operators, it is necessary

place a row of viraza in the paws. Whether there are innumerable rows in a virus

are seen as the names of the changing middle things, the meanings of which are being recreated

have a numerical appearance in front of vikoristannyam. How to change from the designated names

is not assigned to the system; instead, zero values ​​are substituted. Tse

allows you to convert arithmetic operations with the values ​​of variable midpoints,

Moreover, it is not necessary to enter % signs to remove the value. What's the team?

SET /A is called from the command line, not from the batch file, you will see

Residual value of vislovlyuvannya. Evil from any operator assigned

May be worth a changeable middle. Numerical values ​​are seen as

tens, since they are not preceded by the prefix 0x for hexadecimal numbers,

and 0 for high numbers. For example, the numbers 0x12,

ta 022 mean tenth number 18. Revert your respect to record

The following numbers are: 08 and 09 are not valid numbers, in addition to

In the octal system, the numbers 8 and 9 are not corrected.

The /P key allows you to set the change value for the input row entered

koristuvachem. Shows the requested promptString before reading

entered row. The promptString request may be empty.

The setting of the changeable center can be expanded as follows:

%PATH:str1=str2%

expand the function of the PATH change medium by replacing the skin input "str1"

expanded result "str2". "str2" can be an empty row for

Effectively view the input "str1" from the extended view. "str1" can

begin from a star, and in this case it will be reported to someone

from the beginning of the expanded video to the first entry, decide "str1".

You can also expand the rows vikorista.

expand the activity of the PATH exchange center, then vikoryst 5

characters that begin with the 11th character (missing 10) of the expanded

result. If the dovzhin is not included, the vikory is charged too much for the fees

value of change. What are the offensive values ​​(the amount and the number of characters that are skipped)

negative, such values ​​that will be vicorized if the value of the exchange is the last

middle, added to the designated value of the pass or designated dovzhin.

Extract the remaining 10 characters from the PATH change.

Extract all symbols of the variable PATH, except the remaining 2.

It's time, encouragement has been added to the hour of death for the changeable middle

sharp. For getting ready, this support is given. Key /V command line

CMD.EXE allows you to install and uninstall it. To click on the button, type CMD /?

Due to the hour of Vikonannaya for the changeable middle of the sharpened color when going around

the boundary of early communication, which occurs when you first read a text

rows, and not under the hour їїї вїї вїї вїкїння. The offensive butt demonstrates guilt

problem with the prevention of early communication:

set VAR=before

If "%VAR%" == "before" (

if "%VAR%" == "after" @echo The body of the internal equalization operator

This information about nothing is displayed, because %VAR% in both IF viruses

is substituted at the moment of the first vikoristanya at the first IF, including in the body

first disassembly IF, which is a warehouse virus. In IF in the middle

warehouse expression actually equals the value of "before" and

"after", which is obviously disgusting. The offensive butt demonstrates the following behavior:

set LIST=

For %i in (*) do set LIST=%LIST% %i

In this case, the list of files in the stream folder will not be recalled. Zamist

The value of the changed LIST will be the name of the remaining file found.

And again it became the case that %LIST% is presented only once -

at the moment of processing the FOR virus, if the list is still empty.

In fact, the aiming fragment is equivalent to the buttstock:

for %i in (*) do set LIST= %i

In what name the remaining found file is saved in the modified LIST.

Due to the hour, the end of the day for the changeable middle is definitely awaited for

vykoristannya special symbol (sign sign), which means

The performance was carried out at the hour of the Viconn. As indicated by the support of the connection

time to finish, then to achieve the results you need to focus

fragments of the guilt were changed as follows:

set VAR=before

If "%VAR%" == "before" (

Set VAR=after

If "!VAR!" == "after" @echo The body of the internal equalization operator

Set LIST =

For %i in (*) do set LIST=!LIST!%i

When expanding the expanded command processing, a number of changes are available

middle elements that are not displayed in the list, but are displayed when the SET command is pressed.

The values ​​of these changes are calculated dynamically immediately after they are calculated.

If the correspondent clearly specifies changes with one of these names,

then this value overlaps the uniquely dynamic value,

described below:

%CD% - opens next to the stream directory.

%DATE% - displays the exact date, similar to the format of the DATE command.

%TIME% - displays the exact date based on the format of the TIME command.

%RANDOM% - a number between 0 and 32767 is displayed at the top ten.

%ERRORLEVEL% - is displayed at the exact value of ERRORLEVEL

%CMDEXTVERSION% - opens at the exact version value

extended command processing

%CMDCMDLINE% - opens the output command row that you click on

command processor