run exe from command prompt

How do I run a .exe file from the command prompt?

For example, if the .exe file is located at C:\file.exe, how do I run this file when the prompt is currently in another location like D:\?


You can either run it by using the explicit path:

c:\file.exe

or add its location to the path (I always have a c:\bin directory to hold my little snippets - not really a kosher location for multiple-user Windows, but none of my Windows installs are multiple-user):

copy c:\file.exe c:\bin  :: put it in a better directory.
path %path%;c:\bin       :: if not already in the path.
file                     :: run it (unless there is another 'file' in path).

Note that, with that second solution, you should be setting up your path so that it's available whenever you start up (in autoexec.bat if you're really using DOS or from the Control Panel -> System -> Environment window if you're using Windows).

And, do note that, if you use the control panel solution, that doesn't affect currently open command windows - you'll need to shut them down and re-open to pick up the new environment variable.


if you are on your D: drive you still able to type " c:\file.exe"


You should add the c:\ path into your Windows system PATH so whatever drive you are in and when you execute the file.exe windows will look at your defined path and run your program there.

TO do this go to Windows -My computer -click right for Properties - Advanced Button - Environment Variables - at the buttom of the windows you will see the PATH - Edit it add ;c:\ and save This should work - I think it will need a reboot