-1

I have written a batch file in my user folder, which I use a lot. Is there any way that I can call it from cmd when I am working in a different folder, without writing out the full path?

4

1 回答 1

1

The location has to be in the system %PATH% for it to be executable directly in cmd. You can see the current %PATH% by typing in echo %PATH% in the cmd.

So you have two options: Either add your script directory to the %PATH%, or put your script in a location that is already contained in the %PATH%.

To add the directory to %PATH%, selecting System from the Control Panel, select the 'Advanced' tab, then the 'Environment Variables' button and then find the PATH (user or system) and edit it. Just append ";" to it.

But adding the entire directory can be dangerous as it will let all executables in your script directory be accessible directly from cmd. A better way, in my opinion, is to copy your script to a directory that is already there in %PATH%, like Windows\System32.

于 2013-09-21T15:17:00.920 回答