I mean, if i'm in the folder foo, and within it there's another folder called bar, and whithin bar folder, there's a file.bat. In this scenario, i can't just type foo/bar/file.bat. I have to type the entire path to get the file executed, i.e (c:/foo/bar/file.bat).

Is there a way i can do just foo/bar/file.bat and execute the file.bat, without having to type the entire path to the file.bat?

P.S: I'm talking about Windows Command Prompt.

Sorry for my bad english.


Your example code has forwards slashes instead of backward slashes (if you didn't notice).

Yes, if you are in foo with command prompt you can run bar\file.bat to open that batch script. You would not run as you say " foo\bar\file.bat " because you are already in foo, as you have said. But if you are in a different node (i.e C:\foo\john) and want to access bar\file.bat you must run ..\bar\file.bat

If you want to navigate to any folder you may run cd [nextfoldernodename]. For example if you are in C: you may run cd foo to get in the foo folder, or if you type cd foo\bar you can get in the bar folder. (cd stands for change directory).

| improve this answer | |
  • But i want execute the file without having to move into its containing folder. – Seu Madruga Aug 3 '17 at 23:43
  • 1
    I solved it. I just had to type .\path\to\mybat.bat Anyway, thank you for your support. – Seu Madruga Aug 3 '17 at 23:46
  • @inovapixel, you shouldn't require that .\ in order to access it though, is it not working without it? Because usually that is an additional symbol (unnecessary) to access the folder you are in. In CMD it should be unnecessary. – El8dN8 Aug 3 '17 at 23:50
  • No, it's not. I tried /path/file.bat, \path\file.bat and it only worked with the . before the rest of the path – Seu Madruga Aug 3 '17 at 23:51
  • @inovapixel, does it work without the slashes at the beginning of the command line? – El8dN8 Aug 3 '17 at 23:54

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.