Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I open Cygwin in rxvt, running wmic does not show the expected wmic:root\cli> prompt. If I execute C:\cygwin\bin\bash.exe from cmd.exe, running wmic inside bash.exe returns the expected prompt. Why?

I have the environment variable CYGWIN set to ntsec tty. I can echo "hello" with a response and everything else seems happy. It's just when I run wmic and a few other Windows applications that have a prompt, the prompt never appears.

share|improve this question

For wmic, try using echo '' | wmic <query here>, where <query here> is your desired query.

For instance, to get a Dell machine's service tag over SSH: echo '' | wmic bios get serialnumber.

Getting interactive mode to work seems fruitless to me, but this should expose most of wmic's functionality to you.

Failed Attempts:

One alternative solution I read was to use < /dev/null at the end instead of an echo '' | in the front, i.e.: wmic bios get serialnumber < /dev/null. I am not, however, having luck with this one. (from Nabble thread)

Another alternative solution I read was to attempt to set tty in the CYGWIN environmental variable. That had no luck for me, either. (from a Larry Hall posting on the Cygwin mailing list, not linked due to spam prevention)

share|improve this answer

It's ye olde Cygwin pty vs native console app issue. Rxvt is based on a "pseudo terminal device" (pty), which Cygwin implements using Windows pipes. Non-Cygwin apps only see the Windows pipes though, which makes some of them think that they should enter non-interactive mode without a prompt. (More specifically, the isatty() function returns false when invoked on a pipe.)

share|improve this answer
So, any idea on how to fix it? I'm I stuck using cmd.exe for certain things? – User1 Jul 21 '10 at 18:55
Some programs have an option to explicitly tell them to enter interactive mode, e.g. 'python -i', so check whether wmic has one of those. Otherwise, puts a nicer interface on the Windows console. – ak2 Jul 21 '10 at 19:43

Depending on the version of Cygwin you are using, you may have to leverage the < /dev/null. I believe I am using 1.7 and I no longer must use < /dev/null on most versions of Windows (the exception is Windows 2003 R2, you still must use < /dev/null.)

Here is an example:

wmic bios (works on almost all versions of Windows) wmic bios < /dev/null (works on all versions of Windows based on my testing)

Hope this helps.

share|improve this answer

echo not required.

Run in cygnin prompt:

Administrator@darwin-test7-wi ~
$ wmic pagefileset where 'name="C:\\pagefile.sys"' delete
Deleting instance \\DARWIN-TEST7-WI\ROOT\CIMV2:Win32_PageFileSetting.Name="C:\\pagefile.sys"

Instance deletion successful.

Administrator@darwin-test7-wi ~
$ wmic pagefileset create name="C:\\pagefile.sys"

Instance creation successful.

Administrator@darwin-test7-wi ~
$ wmic pagefileset where 'name="C:\\pagefile.sys"' set InitialSize=512,MaximumSize=512

Updating property(s) of '\\DARWIN-TEST7-WI\ROOT\CIMV2:Win32_PageFileSetting.Name="C:\\pagefile.sys"'

Property(s) update successful.
share|improve this answer

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.