Suppose I have a program named any_program.exe
and my operating system drive is C:
.
The location of the program is D:\Any_Folder\any_program.exe
How do I start/execute that program via command prompt in Windows 8?
I have tried the command line START any_program.exe
, but it shows me an error that
Windows cannot find 'any_program.exe'. Make sure you typed the name correctly, and then try again.
By the way, it worked perfectly in Windows 7.
And, if I type START notepad.exe
or START firefox.exe
(Firefox is not installed in C: drive), it works in Windows 8.
Best Answer
There are three basic ways to run a 'command' in the Command Prompt.
builtins ("internal commands")
These are commands built into cmd itself, and do not require an external program invocation. They also do not perform any searching, and will always be executed with the highest priority if matched. You can bypass builtins by wrapping the executable name in quotes:
echo
calls the builtin, but"echo"
would search following cmd rules.Direct invocation
This is when you directly specify a program name (without a path). For example, if you run
cmd
(cmd.exe
) oripconfig
(ipconfig.exe
) at the prompt, you are directly calling the external command. This performs limited searching implemented entirely within the Command Prompt, in this order:(thanks to dxiv for the comments)
Through the
start
commandWhen you try to execute a file through the
start
command, Command Prompt does not perform any searching. Instead, it passes the file name (and arguments) over to Windows itself (via theShellExecuteEx
API call), which must then search for the file's location. There are several places it searches in the following order:Note that the Run dialog also uses this search method.
Normally, you can either navigate to the location of the file with
cd /d D:\Any_Folder
(/d
means change drive) and just runany_program.exe
. Alternatively, you can specify the full pathD:\Any_Folder\any_program.exe
.If you want to start it with
start any_program.exe
, you have a couple of options:D:\Any_Folder
) to the PATH environment variable, see this question for details.firefox.exe
) with the full path to the file, unlike the other options that deal with directories. See here for more information.