0

I'm trying to open an exe file located in

C:\someFolder

but since i'm doing it in cmd I do this

C:\ > someFolder\myExe.exe

But the problem is that inside someFolder are some files needed by the program

When I open it from another location, it opens in this particular location and can't access the files.

How should I do ?

EDIT :

I can't simply do CD first.

I want to call the exe in the context menu, so I have to add this command in a regristry KEY

4 Answers 4

2

Simply switch to the folder first:

cd /d C:\someFolder
myExe.exe
1

First you have to navigate to Somefolder.

Type in C:\>cd someFolder enter

Your prompt will look like this: C:\someFolder>

Now you can execute your program by typing myExe

0

Another method to run .exe file in command prompt

cmd /K “C:\SomeFolder\MyApp.exe”

Note: Don't forget to run command prompt with administrative privileges.

-2

Changing the directory manually and then running the executable is fine for one off requirements. If you need to run this program multiple times consider adding a path variable. This lets you add the c:\somefolder to the path variable on your computer. Once that is added you can just type myExe.exe from the command prompt without adding the path to the file. Add a path variable by:

  • Opening File Explorer
  • Right-click on 'Your Computer' and select 'Properties'
  • Select Advanced System Settings
  • Click on 'Environment Variables'
  • Scroll down the list of system variables and select 'Path'
  • Click 'Edit'
  • Add ;C:\somefolder (note the semicolon that ends the last path statement) and click 'OK'

You should now be able to run your executable from the command prompt

1
  • 1
    If the program looks for files only in the current working directory, how will adding its location to the PATH help? It will help the OP launch the program without needing to specify the path every time, but the CWD problem will still remain.
    – Karan
    Commented Jun 12, 2015 at 15:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .