44

After a bit of googling and searching here, couldn't find the answer to this silly question!

For a structure like this...

dirZero
|---dirOne
|---|---myProgram.exe

How do I run "myProgram" if my current directory is dirZero? I.E.,

C:\dirZero> dirOne/myProgram.exe

...which obviously doesn't work. Thanks in advance.

  • 2
    the interesting part is that if myProgram was in dirZero and you were in dirOne, then you could do "..\myProgram.exe" and it would run the EXE in the previous directory. – EpicPandaForce Jul 28 '14 at 8:35
77

You should use a backslash \, instead of forward slash. /

C:\dirZero> dirOne\myProgram.exe

Or, wrap it with double quotes "

C:\dirZero> "dirOne/myProgram.exe"
  • 6
    Got it thanks. facepalm – Ben Oct 11 '10 at 3:12
  • 2
    I think you should move the second one with double quotes to the top as it is more intuitive for people who are looking for this answer. – Priya Ranjan Singh Jun 18 '15 at 15:02
  • Thanks for this. I wrote a Python script in Linux that contains code to call some binaries in other directories. I recently tried to run the same script in Windows and couldn't figure out why it wasn't working until I read this answer - solved my problem. +1. – rayryeng Apr 7 '17 at 3:24
  • Does anyone know what CWD for the program is set to in this case? Is it C:\dirZero or C:\dirZero\dirOne? – igor Jul 24 '18 at 14:33
13

Use a backslash instead

C:\dirZero> dirOne\myProgram.exe
-4

probably u should just simple use

cd C:\dirZero\dirOne
C:\dirZero\dirOne> myProgram.exe
  • 4
    This is not the question being asked. Read it more carefully. – rayryeng Apr 6 '17 at 5:24
  • And in some cases it will do different result, as working directory would be different. For example if you call npm/yarn – BotanMan Feb 7 '18 at 6:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.