Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

/? 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.

share|improve this answer
on my win xp sp2 latop this following code snippet would work: cygstart /cygdrive/c/WINDOWS/system32/cmd –  Michael Mao Jan 31 '11 at 6:05
add comment

You can run a batch file from a Cygwin shell directly, you don't even need the intermediate call to cmd. If the batch file requires arguments, they need to be quoted in the Windows fashion; it might be simpler to run cmd /c 'foo.bat "quoted arguments"'.

You don't say in what terminal you're running the shell. Batch files by themselves don't care about that, but the commands that are executed from the batch files might. Cygwin terminal emulators do not emulate Windows consoles, so they are good for Cygwin programs and for stdio-only programs but not for Windows console programs.

If normally run Cygwin shells in a Cygwin terminal (such as rxvt or mintty), You can run the trouble batch files in a separate Windows console with start foo.bat. You might want to run Console2 as a better replacement for the Windows console, and run Windows console applications in Console2 and Cygwin applications in a Cygwin terminal (or even in Console2).

cmd /? is a red herring: there are presumably one-character-long directories in the Cygwin root directory, so the shell expands /? and runs cmd with switches that happen to produce no output.

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.