It is not uncommon for advice on certain actions and fixes in Windows 10, 8 and Windows 7 include steps like: “create a .bat file with the following content and run it”. Despite this, a novice user doesn't always know how to do it and what that file is.
This instruction details how to create a bat script, run it and some additional information that may be useful in the context of the topic at hand.
Create a .bat file with notepad
The first and easiest way to create a bat file is to use the standard Notepad program, present in all current versions of Windows.
The steps to create a bat file are as follows
- Run Notepad (located in Programs – Standard, in Windows 10 it's faster to run via taskbar search, if Notepad is not on the Start menu, you can run it from C: Windowsnotepad.exe).
- Write the code of your bat file in notepad (as an example, copy it from somewhere or write your own in some commands later in the instructions).
- In the notepad menu, select File – Save as, choose where to save the file, specify the file name with a .bat extension and be sure to determine “All the files” in the countryside “Type of file”.
- Click the button “Keep”.
Note: If the file is not saved in the specified location, as drive C, with the message “You do not have permission to save files in this location”, save it in the Documents folder or on the desktop and then copy it. to the desired location (the reason for the problem is that Windows 10 you need admin rights to write to some folders and, since Notepad was not run as administrator, cannot save the file in the specified folder).
Your .bat file is ready: if you run it, all the commands listed in the file will be executed automatically (as long as there are no errors and admin rights are required; in some cases, it may be necessary to run the bat file as an administrator: right click on the .bat file, run as administrator from context menu).
Note: in the future, if you want to edit the created file, you just have to click with the right mouse button and choose "Edit".
There are other alternatives to create a bat file, but they all boil down to typing the commands one command per line in a text file in any text editor (without format), which is later saved with a .bat extension (as an example, in Windows XP and Windows 7 of 32 bits, you can even create a .bat file on the command line using the edit text editor).
If you have file extensions enabled (cambio en el panelA panel is a group of experts that meets to discuss and analyze a specific topic. These forums are common at conferences, seminars and public debates, where participants share their knowledge and perspectives. Panels can address a variety of areas, from science to politics, and its objective is to encourage the exchange of ideas and critical reflection among the attendees.... Control – browser options – watch – hide extensions for registered file types), then you can simply create a .txt file and later rename the file by putting the extension. bat.
Running programs in a bat file and other basic commands
You can run any program and command from this list in the bat file: https://technet.microsoft.com/ru-ru/library/cc772390(v=ws.10).aspx (even though some of those listed may not be available in Windows 8 and Windows 10). Here is some basic information for novice users.
The most common tasks are: run a program or multiple programs from a .bat file, execute some function (as an example, clear clipboard, dole out Wi-Fi from a laptop, turn off the computer with a timer).
To run one or more programs, use command
start "" path_to_program
If the path contains spaces, enclose the entire path in double quotes, as an example:
start "" "C:Program Filesprogram.exe"
After the program route, además puede especificar los parametersThe "parameters" are variables or criteria that are used to define, measure or evaluate a phenomenon or system. In various fields such as statistics, Computer Science and Scientific Research, Parameters are critical to establishing norms and standards that guide data analysis and interpretation. Their proper selection and handling are crucial to obtain accurate and relevant results in any study or project.... con los que se debe ejecutar, as an example (in addition, if execution parameters contain spaces, enclose them in quotes):
start "" c:windowsnotepad.exe file.txt
Note: The double quotes after the startup specifications should specify the name of the script file that appears in the command line header. This is optional, but running bat files containing quotes in paths and parameters may unexpectedly fail if these quotes are missing.
Another useful function is to run another bat file from the current file, this can be done with the call command:
call path_to_bat_file parameters
Parameters passed at startup can be read from another bat file, as an example, we call the file with parameters:
call file2.bat parameter1 parameter2 parameter3
In the file2.bat we can read these parameters and use as paths, parameters to run other programs in this way:
echo %1 echo %2 echo %3 pause
In other words, for each parameter we use its sequence number with a percent sign. The result of the previous example is the output to the command window of all the parameters passed(the echo command is used to send text to the console window).
By default, the command window closes as soon as all commands are executed. If you want to read the information inside the window, use pause command; will stop the execution of the commands (or close the window) until you press any key on the console on the user side.
Sometimes it is necessary to wait a while before executing another command (as an example, until the first program runs completely). To do this, you can use the command
timeout / t time_in_seconds
If you wish, you can run the program in minimized or expanded video using the MIN and MAX parameters before specifying the program itself, as an example
start "" /MIN c:windowsnotepad.exe
To close the command window after all commands have been executed (even though it regularly closes anyway when you use start to run it), use exit command in last line. In case the console still does not close after starting the program, try using this command:
cmd /c start /b "" path_to_program parameters
Note: in this command, if program paths or parameters contain spaces, there may be startup problems, that can be solved like this:
cmd /c start "" /d "path_to_folder_with_spaces" /b program_file_name "parameters_with_spaces"
As noted, this is just a very basic introduction to the most used commands in bat files. If you need to perform additional tasks, try searching the internet (look for an example “do something on the command line” and use the same commands in the .bat file) or ask a question in the comments, I will try to help you .
In case this is also of interest:



