Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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:\?

share|improve this question

migrated from stackoverflow.com Dec 2 '09 at 1:23

This question came from our site for professional and enthusiast programmers.

6 Answers 6

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.

share|improve this answer

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

share|improve this answer

To switch drives, just type C: and push enter. To change directories, type cd somedirectory.

Let's say I am at D:\Brad and I want to run C:\Windows\notepad.exe. You could either just type it's name explicitly like others have suggested, or you could do this:

C:
cd \Windows
notepad
share|improve this answer

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

share|improve this answer

The best way to run an EXE file that you don't known its full name is:

Assuming your file name is Installer_4756873653.exe but you don't know the full name after the Installer_ and the location of the file is C:\

cd C:\
dir Installer_*.* /b > FileToRun.bat
FileToRun.bat
share|improve this answer
2  
Why not just type "Installer" and then hit tab? –  Daniel R Hicks Mar 1 '12 at 16:31

Create .bat or .cmd file and write content to

cd your_directory_one start filename.exe

cd your_directory_second start filename.exe

it work for me

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.