I have Cygwin running on a Windows 7 machine and have the Cygwin ssh server running on it. On Linux I have a shell script where I want to do
ssh myuser@mymachine "qwinsta | grep Active"
to see who is logged in. This worked fine for a Windows Server 2008 R2 machine, but seems to have problems on Windows 7.
If I try this on the Windows 7 machine, I get:
bash: qwinsta: command not found
Now, here is where the weirdness begins…
If I login to the Windows 7 machine normally and look in C:\Windows\System32 with Windows Explorer, I see qwinsta.exe. If I open a CMD session and do a dir in C:\Windows\System32, I see qwinsta.exe. If I open a Cygwin shell and do a ls qwinsta.exe in /cygdrive/c/Windows/System32, I get:
ls: cannot access qwinsta.exe: No such file or directory
If I do a cmd /c dir C:\\\\Windows\\\\System32\\\\qwinsta.exe from the Cygwin shell, I get a “File Not Found”
If I copy qwinsta.exe into my Cygwin home directory, then it is visible in my home directory with ls. If I try to run this local copy of qwinsta from the Cygwin shell, it runs, but it also outputs a line:
{Message(): LoadString failed, Error 15105, (0x00003B01)}
What’s up with qwinsta on Windows 7?
The problem is that
qwinsta.exeis not actually located inC:\Windows\System32. It is actually found inUsing the above path (or a softlink to the same) will run
qwinsta.exeas it exists on any machine, and will not require you to copy the executable to your home directory.The error message
{Message(): LoadString failed, Error 15105, (0x00003B01)}is about the Multilinugal User Interface (localization) system not being able to find error message localization information for the program being run (see System Error Codes). In this case, it appears that the cygwin shell does not provideqwinsta.exewith the information it needs to findqwinsta.exe.muiin your language’s locale folder (usuallyC:\Windows\System32\en-USor whatever your locale happens to be). Looking into this folder is somewhat misleading, as explorer will show the file in this directory, but when you runls /cygdrive/c/Windows/System32/en-US, there is noqwinsta.exe.muifile. I suspect this has something to do with the new linking structure in NTFS (see mklink command), but I haven’t figured out how to fix this part of the problem yet.