9

When I execute a command with the same name as an internal command, instead of searching in the path Windows simply uses the one found in CMD.EXE.

For example, MKDIR is an internal command built into CMD.EXE. It does not support the same options as the Unix version (e.g. -p and --help). If I use these options Windows will simply create files named -p or --help even though I have the GNU version of mkdir installed in a directory in my path.

This becomes an issue when working with certain programs that use mkdir through the terminal. For example, the gulpfile for prose contains three mkdir -p commands that, create a folder -p in the working directory and then throw errors. I have to manually edit the gulpfile such that it uses the installed mkdir.exe, which makes it harder for me to share my fork cross-platform.

How can I force the Windows shell to use the mkdir.exe found in PATH rather than CMD.EXE?

0

1 Answer 1

14

How can I force the Windows shell to use the mkdir.exe found in PATH rather than CMD.EXE?

Surround the executable name in double-quotes. For example:

"MKDIR"

This forces Windows to look for your executable instead of running the internal command. If you have parameters that also require double-quotes, use this syntax:

"MKDIR" -firstParam "C:\foobar\long file name.ext"
3
  • 1
    Alternatively you should be able to specify the full path to the mkdir program you wish to call.
    – davidgo
    Commented Dec 24, 2014 at 22:19
  • Unfortunately this does not work. What it does is it creates a new file named ".exe" in the current directory. @davidgo I can specify the whole path, but that becomes an issue with sharing my code with others: not everyone has mkdir located in C:\Program Files (x86)\Git\bin\mkdir.exe! Commented Dec 24, 2014 at 22:30
  • 2
    Surrounding in double quotes works! You don't even need to specify the extension -- just "mkdir". Thanks! Commented Dec 24, 2014 at 22:37

You must log in to answer this question.

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