How do I open a program via the command prompt in Windows 8?
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.
Solution 1:
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:- The current directory.
- The directories that are listed in the PATH environment variable.
(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:- Current working directory
- Windows directory
- Windows\System32 directory
- Directories listed in PATH environment variable
- Registry defined App Paths
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 run any_program.exe
. Alternatively, you can specify the full path D:\Any_Folder\any_program.exe
.
If you want to start it with start any_program.exe
, you have a couple of options:
- You can put it in the Windows or System32 directories, or any directory in the PATH environment variable.
- You can add the directory it is located in (
D:\Any_Folder
) to the PATH environment variable, see this question for details. - You can add it to the App Paths registry key, as Notepad and Firefox does. App Paths links a file keyword (such as
firefox.exe
) with the full path to the file, unlike the other options that deal with directories. See here for more information.
Solution 2:
start D:\Any_Folder\any_program.exe
or, when path or file contains spaces
start "" "D:\Any_Folder\any_program.exe"
start any_program.exe
works only for those programs, who are located in %PATH%
environment variable, or registered in registry in the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
or its HKEY_CURRENT_USER
analogue.
Solution 3:
You have two options:
- Add the program to your
%PATH%
variable - Use quotes in your shortcut
Detail:
Adding any_program.exe
to path:
-
Go to "Control Panel" ->"Advanced System Settings"
-
Go to the Advanced tab
-
Click on "Environment Variables" Add the folder in which any_program.exe resides. Edit the PATH Variable and add the folder in the end, separated by a
;
-
You can now use any_program.exe in the run dialog box (Try logging out and back to make sure your path variable changes are used.)
Using complete path
Instead of using any_program.exe
in the Run dialog, you need to use the complete PATH. So type D:\Stuff\App\any_program.exe
in the run dialog instead.
Solution 4:
- Open Command Prompt
- Type the name of the program you want to run. If its on the PATH System variable it will be executed. If not, you'll have to type the full path to the program. For example, to run D:\Any_Folder\any_program.exe type D:\Any_Folder\any_program.exe on the Command prompt and press Enter
Solution 5:
I am using a yet simple method . . .
Copy the shortcut of the file to C:\users\name
and then type the shortcut's name in run dialog box. . . . .