69

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.

starball
  • 20,030
  • 7
  • 43
  • 238
Ben
  • 54,723
  • 49
  • 178
  • 224
  • 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

111

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
  • 15,438
  • 7
  • 38
  • 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
  • 64,563
  • 18
  • 145
  • 216
-6

probably u should just simple use

cd C:\dirZero\dirOne
C:\dirZero\dirOne> myProgram.exe
pumamammal
  • 61
  • 1
  • 9
  • 7
    This is not the question being asked. Read it more carefully. – rayryeng Apr 06 '17 at 05: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 07 '18 at 06:35
  • See also [What exactly is current working directory?](https://stackoverflow.com/questions/45591428/what-exactly-is-current-working-directory/66860904) – tripleee Dec 06 '22 at 08:00