JoeyJoeJoeShabadoo
JoeyJoeJoeShabadoo

Reputation: 11

Windows Run can't find batch file

I created a very simple batch file that works when I double click the file, but if I try to launch it by typing in the name of the batch file into Windows Run, Windows is unable to find it. If I type in the name of the folder containing the batch file, the folder opens up.

Fairly new to coding. I'm going through "Automate the Boring Stuff" book

Upvotes: 1

Views: 1163

Answers (1)

arealpersononstack
arealpersononstack

Reputation: 51

Run searches the folders in your global %PATH% variable for your file. It's unlikely that your script is in one of the directories mentioned in %PATH%.

To see the contents of PATH, type ECHO %PATH% into a command prompt. You can then move your script to one of the directories.

Alternatively, to temporarily (for the current CMD session) add a directory to PATH, run SET PATH=%PATH%;C:\path in your command prompt. A permanent change in PATH requires use of the registry.

I recommend you reconsider this approach however, as launching CMD then navigating to the script's location (CD C:\path) to then run the script is generally preferable to changing global variables.

Upvotes: 2

Related Questions