Wmic hangs in Cygwin

cygwinwmi

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.

Best Answer

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)