As you know, operating systems with graphical user interfaces are not always "hosted" on computers. Even before their appearance, DOS-like operating systems were often used, in which it was necessary to enter special commands in order to perform any actions. And it was from them that the principles of creating and executing the so-called batch files were borrowed.

Despite Microsoft’s loud claims that MS-DOS support was discontinued a long time ago if you think about it thoroughly, it’s easy to realize that the same command line or PowerShell console works according to the same principles. And for them sometimes to enter any specific commands that initiate the execution of certain actions, it is not necessary. You can easily write your own code and save it in a special BAT-file, after the launch of which actions will be executed automatically. But how to create a BAT file in Windows 7 or OS below or above? To do this, there are several simple ways, which will be discussed further. But first, you need to find out what these objects are and what they can be used for.

What is a batch file?

In general, today there are two main types of such files, dividing them exclusively by extension: either BAT or CMD. Since such objects are very similar to each other in terms of content and performance, so that there is no confusion, we will consider questions related to how to create a BAT file in Windows 7 and above (although the proposed solutions equally apply to earlier modifications).

BAT-file, or in common "batch file", is the most common text document that contains a set of specific commands that are executed sequentially as you move from one line of code to another. However, sets can contain many additional operators, including looping the execution of an action (loop) or transitions subject to certain conditions (if, goto, etc.). If you look at the two-second operators, it will become clear to many that they have been used in such ancient and primitive programming languages, to which the same Basic can be attributed. Despite this, they are also successfully used in more “advanced” languages at the present stage of the development of computer technologies (for example, when writing scripts in VB or Pascal).

What are batch files for?

As for the purpose of such files, most of them are used to automate some, if I may say so, routine processes, most often associated with primitive actions such as copying or moving data, sequentially running several programs, etc. For some reason, it is considered that this is the prerogative of system administrators, however, many users may also need to know the structure of such objects (for example, to run certain types of applications in the Windows environment via the command line, if Starting an EXE file for some reason is blocked by the operating system, or some system setting is not available for editing).

Windows batch file examples

We will talk about how to create a BAT file in Windows 10 and below, but in the meantime, in order to bring final clarity on the most efficient use of such objects in Windows systems, consider several interesting examples.


So, probably, all those users who once worked with the first modifications of Windows, know that they previously had a special file Autoexec.bat, which is responsible for the configuration of the system when it starts, and the user could add commands to perform it applications like clearing disk space, creating copies of important data, etc. It is only much later that a special configurator appeared in the system, called by the msconfig command.

Another rather unusual example can be given for tablet PCs based on Windows RT versions 8 and 8.1, in which applications are installed exclusively through the Windows “Store”, and third-party software cannot be installed.

The solution was found and presented by a group of enthusiasts in the form of a small utility RT_Jailbreak 1.20, which contains a batch file that allows you to disable the verification of digital signatures of installed applications (without the Microsoft signature, the installation is impossible, as well as disabling the checks by means of the system itself, in which such tools are blocked) .

No less interesting is the batch file from the Windows RT Development Toolset, which allows you to restart the system in developer mode.

And, of course, the SignTool program, represented just in the form of a batch BAT-file, turned out to be a very necessary utility, allowing for any software and its components to be in the form of executable EXE files and accompanying DLLs, so to speak, “re-signing” with the original digital signature on a Microsoft signature.

How to create BAT-file in Windows through the "Explorer"?

But back to the creation of batch objects. How to create a BAT file using the built-in file manager of the system? Elementary!


Through the RMB on the empty space in the given location, select the section "Create ...", and then go to the point of creating a text document. After its appearance in the working area, the file must be simply renamed, giving it an arbitrary name and the corresponding BAT extension through a dot. Please note that when performing such an operation, the display of extensions must be enabled.

How to create a file with BAT extension in Notepad?

Since, as mentioned above, the “batch file” is a text file, there is another solution that involves the use of the standard text editor Notepad. How to create a BAT file in this case? Easy too!


Enter the necessary commands, and then use the file menu to save the file, but in the document typeset “All files”, and in the name field enter the desired name with the BAT extension through a dot. User feedback suggests that this method is used most often.

Note: just in case, it is worth noting that registry files are created in the same way, if necessary.

Using FAR File Manager

Finally, consider how to create a BAT file in one of the popular file managers called FAR Manager, which was created in the image and likeness of the “Norton Grandfather” (Norton Commander).


To do this, use the Shift + F4 key combination, after which its name is entered in the file name field with a dot extension, the enter key is pressed, and the empty file is saved by pressing Shift + F2, which corresponds to the Save As ... command . You can edit the content with the input of the necessary commands through the corresponding function “Edit”, called by pressing the F4 key. As for the teams, it is better to study them beforehand. But for all those who want, for example, to create a folder via a BAT file, you can offer the command MKDIR or its shortened version MD FolderName, where FolderName is the name of the directory. By and large, the command can be complicated by specifying the location on the disk and selecting a user. Anyway, almost all variables can be used for almost all commands,

Epilogue

That's all about the question of how to create a BAT-file in Windows-based systems, using a few simple means. Which one is the easiest is up to the user to decide, however, for the convenience of simultaneously creating a “batch file” and editing it, it is best to use either Notepad (or another similar text editor) or FAR Manager.

  • Videos for this article

  • Batch/Cmd Programming: Lesson 1 (Basics)
    Batch/Cmd Programming: Lesson 1 (Basics)
  • How to Write a Simple Batch File in Windows
    How to Write a Simple Batch File in Windows
  • How to create a simple batch file
    How to create a simple batch file
  • Automating Work with Bat Files and How to Use Them
    Automating Work with Bat Files and How to Use Them
  • What is Batch File, How It Works and How To Create Batch File | In Hindi/Urdu |
    What is Batch File, How It Works and How To Create Batch File | In Hindi/Urdu |