Running a file from Command Prompt means typing its name or full path and pressing Enter

Command Prompt executes programs and scripts when you type their name and location. If the file is in your current folder, you type just the filename. If it is somewhere else on your computer, you type the full path — the complete address from your drive letter down to the file itself. Either way, Command Prompt finds the file and runs it.

The method changes slightly depending on what kind of file you are running: a program (.exe), a batch script (.bat), a Python script (.py), or something else. The core idea stays the same: tell Command Prompt where the file is, and it will start it.

Key Takeaways

  • Type the filename alone if the file is in your current folder, or type the full path (starting with C:\ or another drive letter) if it is somewhere else.
  • Use quotes around any path or filename that contains spaces, like "C:\Program Files\MyApp\program.exe".
  • Find your current folder by looking at the text before the cursor in Command Prompt, and change folders with the cd command if you need to move to a different location.
  • Run batch files (.bat) and executable files (.exe) by typing their name; run Python scripts (.py) by typing python followed by the filename.
  • If Command Prompt says the file is not found, check that the path is correct and that you spelled the filename exactly as it appears on your computer.

Finding where your file is located

Before you can run a file, you need to know its full path — the complete address of where it lives on your computer. Open File Explorer, find the file, and look at the address bar at the top. That address is what you type into Command Prompt.

For example, if you see C:\Users\YourName\Documents\myscript.bat in the address bar, that is the full path. Write it down or copy it. If the path contains spaces (like "Program Files" or "My Documents"), you will need to put the whole thing in quotes when you type it into Command Prompt.

You can also right-click a file in File Explorer, choose Properties, and look at the "Location" field to see its full path. This method works for any file type.

Running a file in your current folder

When you open Command Prompt, it starts in a default folder — usually C:\Users\YourName. You can see which folder you are in by looking at the text before the cursor. It will say something like C:\Users\YourName>.

If your file is in that same folder, type the filename and press Enter. For example, if you have a file called backup.bat in your Documents folder and Command Prompt is already pointing to Documents, type:

backup.bat

Command Prompt will run it when ready. If the file has spaces in its name, put the whole name in quotes:

"my backup script.bat"

Running a file in a different folder

If your file is not in the current folder, type the full path. Start with the drive letter (usually C:), then the folder names separated by backslashes, then the filename. For example:

C:\Users\YourName\Documents\myscript.bat

If any part of the path contains spaces, wrap the entire path in quotes:

"C:\Program Files\MyApplication\program.exe"

Press Enter, and Command Prompt will find and run the file. If you get an error saying the file is not found, double-check that every folder name and the filename are spelled exactly as they appear in File Explorer.

Changing your current folder to make typing easier

If you are running several files from the same folder, you can change where Command Prompt is pointing so you do not have to type the full path each time. Use the cd command, which stands for "change directory".

Type cd followed by the path to the folder you want to move to:

cd C:\Users\YourName\Documents

Press Enter. Now the text before the cursor will show C:\Users\YourName\Documents>, and you can run any file in that folder by typing just its name. To go back up one level, type cd .. (two periods). To go to a completely different folder, type the full path after cd.

Running different types of files

Most executable files (.exe) and batch files (.bat) run by typing their name. However, some file types need a program to open them. Python scripts (.py) are the most common example.

To run a Python script, type python followed by the filename:

python myscript.py

If that does not work, your computer may not have Python installed, or Command Prompt may not know where to find it. Similarly, if you have a text file you want to run as a batch script, rename it to end in .bat instead of .txt, then run it the same way you would run any batch file.

For other file types — like .vbs (VBScript) or .ps1 (PowerShell) — you may need to type the program name first. PowerShell scripts, for example, require you to type powershell before the filename, and you may need to change your security settings to allow them to run.

What to do if you get an error

The most common error is "is not recognized as an internal or external command, operable program or batch file." This means Command Prompt could not find the file. Check three things: the spelling of the filename, the spelling of every folder in the path, and whether you used quotes if the path contains spaces.

If the file is in a folder that is not in your system's PATH (a list of places Command Prompt searches automatically), you must type the full path. Typing just the filename will not work unless the file is in your current folder or in a PATH folder.

If you are trying to run a program that requires administrator permissions, Command Prompt may refuse to run it. Right-click the Command Prompt icon and choose "Run as administrator" to open a version with higher permissions, then try again.

Frequently Asked Questions

Do I need to type the file extension (.exe, .bat, .py)?

For .exe and .bat files, you can usually type just the filename without the extension, and Command Prompt will find it. For other types like .py or .vbs, you must include the extension. If you are not sure, type the full filename with the extension — it always works.

What if the path has spaces in it?

Wrap the entire path in double quotes. For example: "C:\Program Files\MyApp\program.exe". Without quotes, Command Prompt will stop reading at the first space and look for a file called C:\Program, which does not exist.

How do I run a file that is on a different drive, like D: or E:?

Type the full path starting with that drive letter. For example, D:\Backups\myfile.bat. You can also type just the drive letter (D:) and press Enter to switch to that drive, then use cd to navigate to the folder you need.

Can I run a file by dragging it into Command Prompt?

Yes. Open Command Prompt, type the program name or command you want to use (like python), add a space, then drag the file from File Explorer into the Command Prompt window. Command Prompt will paste the full path automatically, and you can press Enter to run it.

What does it mean when a program runs but nothing seems to happen?

Some programs run silently in the background and do not show output in Command Prompt. Others finish so quickly that the window closes before you can see the result. Try adding pause on a new line at the end of a batch file to keep the window open, or redirect the output to a text file by typing program.exe > output.txt to save what the program prints.