Windows – Running cmd.exe from within Cygwin

command linecygwin;windows xp

I'd like to use Cygwin for my main shell at work, but my group uses batch files for several processes. I've been told that I can just do cmd /c batch.bat to run the batch file from Cygwin. This works for some cases, and not for others. One of the batch files completely fails when I do this, but works fine when I run it from the cmd shell.

Another oddity I've noticed is that if I run cmd /? from Cygwin, I get no output. Running this from the cmd shell gives the standard help. Even doing cmd /c cmd /? provides no output. If I run cmd from Cygwin, it gives me the cmd shell, and then if I run cmd /?, I get the help text, but without the page breaks.

I guess the next thing to try is to find a way to actually launch cmd within its own distinct window, as if you'd gone to Start->Run, and then typed "cmd". Is there a way to do this from within Cygwin?

Best Answer

/? is treated as a pattern by bash, where the question mark will fit a single character, so if you have any one-letter files or directories in your Cygwin root, the pattern will be replaced with those. echo /? will show you if that's what's happening. You can escape the question mark with a backslash: /\?. Or quote the whole argument: '/?'.

cygstart c:/windows/system32/cmd will start cmd.exe in its own window.

Related Question