2

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.

4 Answers 4

6

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)

2

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.)

2
  • So, any idea on how to fix it? I'm I stuck using cmd.exe for certain things?
    – User1
    Jul 21, 2010 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, console.sf.net puts a nicer interface on the Windows console.
    – ak2
    Jul 21, 2010 at 19:43
2

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.

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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