Probably, all Windows users who very often use the command line or PowerShell console tools, which have almost complete analogy to outdated DOS-systems, drew attention to the fact that in the OS itself, despite the priority of access to some features or tools of Windows, sometimes the execution of so-called batch files is required, and it is in console mode. What are they? Ordinary users know almost nothing about it. But advanced users and programmers use the capabilities of such applets quite often. How it all works and why you need it, read on.
What are batch files?
In general, files of this type themselves are applets executable in the operating system environment and contain commands that make a sequential transition to perform one or more operations. As a rule, they have the extension CMD or BAT (less commonly - PS1). Since the contents of such objects are almost the same, we will consider exactly Batch objects, from the English name of which the abbreviation arose, used to indicate the extension that determines the file type.
If you carefully look at the extensions, and the icons, and the properties of the Windows batch files displayed in the same "Explorer", it is easy to figure out that such applets are executed either on the command line or in the PowerShell console. This console is an analogue of the first tool, but with more features. Despite the fact that batch batch files are just programs, in their structure they are no different from ordinary text objects. Only they contain a certain set of commands. It is also very common to find arbitrary text fields (for example, “Press any key to continue”) that appear on the screen when a command is executed, after which confirmation or selection of a user action is required.
main destination
As for the use of batch files, it is believed that they are most often used to start chains of sequential processes in order to automate, so to speak, routine actions. However, few people realize that sometimes they can be used to start other programs in the environment of Windows operating systems, if it is impossible to start them using conventional means (say, due to current restrictions at the system level, as in Windows RT, or in terms of rights for a specific user )
The simplest example of a standard applet of this type can be called the Autoexec.bat file, which was responsible for the system boot configurations, which must be present in early versions of Windows. Please note that the configuration console, called by the msconfig command, appeared relatively recently by modern standards, and it was she who was given all the reins of control by the settings of the OS start parameters.
Batch File Commands
As for the main teams, dealing with them will not be difficult even for the most inexperienced user. If you belong to the generation that at school in computer science lessons studied the primitive programming language Basic, and then, perhaps, Pascal, the similarity of the commands used is obvious. The fact is that the parameters of the batch file are such that they imply the use of command statements that were previously presented in these languages (if, goto, loop, etc.). Usually, the echo command is used to display the execution of commands on the screen or display text messages, which can have the on or off parameters, which corresponds to switching on and off. Often this command is also used to enter some variables or so-called wildcard values (for this additional symbols are indicated).
In general, in order not to deal with the unnecessary description of all the commands, you can invite users to get all the information they need on their own, using the help command line help command. If you need information on a specific command, is either a combination with an assistant (for example, help echo) or a help / command combination used? (e.g. help / AT?). Thus, it is easy to guess that any of the commands working on the command line can be included in the list of operations performed in batch files.
How to create an executable file yourself?
Now let's try to create the simplest file ourselves. For this, any text editor is suitable, including the most common Notepad built into all Windows modifications. You can also use the FAR file manager, which works like Norton Commander. But for convenience, we will dwell on Notepad. For example, through a .bat file, you need to open a text object named Commands on drive D.
Enter the command start D: \ Commands.txt, and then save, select "All files" in the file type field and assign the BAT extension yourself.
After that, run it by double-clicking or through the PCM menu and look at the result. If such a file is not in the specified location, this command can also be used to create it. It will only look like this: start file> D: \ Commands.txt.
Run and Run Features
But this was the simplest example. Usually, to execute the uncompiled commands found in batch files, it is best to use the start of the file as administrator, which is akin to running the command line with these rights. In most cases, this is necessary when performing system settings, bypassing all kinds of locks, etc. This can be called the main requirement, although for many applets there is no need for such a start.
Example of executable file launch
Now consider a few examples. Suppose we have a ready-made script in the form of a BAT file that allows you to restart the operating system in tester mode. Launch the desired applet, press any key to continue, and then get into the action selection menu.
As you can see from the above example, using such a file you can remove system updates, download it in test or normal mode, or get additional information. Entering a specific digit will set the execution of the sequence of commands to which it is assigned.
More complex configurations
If you look at more complex examples, you can suggest looking at a unique scenario of changing the digital signatures of executable files and related dynamic libraries to Microsoft, which is especially often required for installing applications in Windows RT modifications that are in normal mode, except from "Shop", it is impossible to install.
Only in this case, you must first reboot the system in test mode, and then execute the desired script.
Batch Processing Issues
As for batch processing of files, in relation to executable BAT-scripts, such processes can correspond to sequential actions based on the commands contained in the applet. However, batch processing is often understood to mean the same conversion or execution of certain operations as applied not to one but to a group of files. To make it clearer, this can often be seen when converting audio or video formats, when you select several source objects to convert them to another single format after conversion. Batch commands are not used here, but in some ways they have an analogy with the processes activated by launching BAT applets.