Running a batch file in Windows

Author: Christy White
Date Of Creation: 3 May 2021
Update Date: 1 July 2024
Anonim
How to Create a Batch (.bat) File in Windows
Video: How to Create a Batch (.bat) File in Windows

Content

This wikiHow teaches you how to run a BAT file - also called a batch file - on a Windows computer. Batch files offer many possibilities, such as automating regularly recurring tasks. You can run them from the Windows file explorer, or run them from the command window.

To step

Method 1 of 2: Via the Explorer

  1. Open Start click on Go to the folder containing the batch file. Go to the location of the batch file or search by clicking This PC in the left pane, and typing the file name in the search bar at the top right.
  2. Double click on the batch file. To run a batch file, you normally just need to double-click the file. If you are unable to run the file, you can try running it as an administrator.
  3. Right click on the file and select Run as administrator. Depending on what the batch file is programmed for, administrator privileges may be required.
    • Many times, batch files do things that are not immediately visible on your computer, and running them can make changes to your computer behind the scenes. Make sure you know the purpose of the batch file as it may have been executed successfully without appearing to have happened.

Method 2 of 2: From the Command Prompt

  1. Open Start Type cmd in the Start menu. As soon as you start typing, Windows will search according to a filter, which can be seen below the text you type in the Start menu.
  2. Right click on the command prompt click on Run as administrator. You may need to open the command prompt as an administrator, depending on the purpose of the batch file.
  3. Type CD followed by the file location. Type the letters "cd" ("change directory") followed by a space, followed by the location of the folder where the batch file is located. For example, if the batch file is on the Desktop of user "Jacob", then type the following:
    cd / Users / Jacob / Desktop.
    • Do not forget the space between "CD" and the location of the file.
  4. Press ↵ Enter. This changes the current directory to the new location you specified.
  5. Type the full name of the batch file. You type the file name and extension .bat at the end. For example, if the batch file is named "install", you would type install.bat in the command window.
  6. Press ↵ Enter. Runs the batch file. If you see the same command prompt you started with and the cursor blinks, the batch file has finished running.
    • Be aware of any error messages that may appear in the command window during or after the batch file is run, as they can be helpful in figuring out what's going on with the batch file's code should something go wrong.