How to Run Batch (.bat) File in CMD
-
Run Batch (
.bat
) File in CMD by Direct Click -
Run Batch (
.bat
) File in CMD by Providing the Direct Location to the File -
Run Batch (
.bat
) File in CMD Using the Change Directory (CD
) Command
This article will show how we can run a Batch file, .bat
, using CMD.
There are three ways to run a Batch file. Let’s discuss them in the following sections.
Run Batch (.bat
) File in CMD by Direct Click
In this way, you only need to go to your file location and double-click on it. But in this way, the file runs and immediately closes when its task finishes.
So, this way is not preferable if your Batch Script doesn’t show any output at the end.
Run Batch (.bat
) File in CMD by Providing the Direct Location to the File
In this way, you need to provide the exact file location of the command. In CMD, type the exact location with filename on double quote like the following.
"G:\YOUR_DIRECTORY\Test_File.bat"
Run Batch (.bat
) File in CMD Using the Change Directory (CD
) Command
In this way, you have to locate your location using the change directory (cd
) command and directly put the name of your file, as shown below.
CD "G:\YOUR_DIRECTORY\"
Test_File.bat
All of the method we discussed above is only for Windows CMD.
Aminul Is an Expert Technical Writer and Full-Stack Developer. He has hands-on working experience on numerous Developer Platforms and SAAS startups. He is highly skilled in numerous Programming languages and Frameworks. He can write professional technical articles like Reviews, Programming, Documentation, SOP, User manual, Whitepaper, etc.
LinkedIn