65

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.

Ben
  • 51,262
  • 47
  • 169
  • 217
  • 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 08:35

3 Answers3

106

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"
Ruel
  • 14,929
  • 7
  • 36
  • 49
  • 3
    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 07 '17 at 03: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
16

Use a backslash instead

C:\dirZero> dirOne\myProgram.exe
Preet Sangha
  • 62,844
  • 17
  • 138
  • 209
-5

probably u should just simple use

cd C:\dirZero\dirOne
C:\dirZero\dirOne> myProgram.exe
pumamammal
  • 63
  • 9