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?
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 .
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With