10

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

7 Answers 7

16

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.

0
2

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

1

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

1

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
0

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
2
  • 4
    Why not just type "Installer" and then hit tab? Mar 1, 2012 at 16:31
  • Might be useful in a script.
    – vadipp
    Oct 9, 2014 at 13:12
0

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

0

You can also drag and drop the exe file on Command prompt (If UAC is set to low/Using builtin Administrator account) to execute it.

You must log in to answer this question.