Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call a .bat file from any location in CMD on Windows

I have a Batch file which I want to execute in CMD from any directory. Something like this:

File name: MyBatch

Path: C:\MyBatch.bat

Open CMD: c:\Program Files> MyBatch

How can I accomplish this?

like image 865
ByteArray123 Avatar asked Aug 20 '10 19:08

ByteArray123


People also ask

How do I access a .bat file?

Using a BAT file in Windows is as simple as double-clicking or double-tapping it. You don't need to download any special program or tool. To use the first example from above, entering that text into a text file with a text editor and then saving the file with the .

How do I read a .bat file in Windows?

To run a batch file, move to the directory containing the file and type the name of the batch file. For example, if the batch file is named "hope. bat," you'd type "hope" to execute the batch file.


1 Answers

Set that location in your PATH environmental variable.

I wouldn't put it the root or the system directory.

I keep a directory with all my scripts in C:\DRR\CMD

and either set it in the MyComputer GUI or run at the command script:

set PATH=%PATH%;C:\DRR\CMD
like image 71
Rawheiser Avatar answered Oct 14 '22 05:10

Rawheiser