How to get query command on Windows 10
I have a Windows 10 computer on which I need to see what users are logged in via an SSH connection (which is the command prompt). I figured I could run query user
on the machine, but the query
command is not installed. Where can I get it? To clarify, this is a Windows Command prompt command that comes installed on most windows servers. I dont have query.exe and want to get it on my computer...
Solution 1:
Windows 10 Home does not include query.exe
. query.exe
is part of Windows Remote Desktop Services (previously called Windows Terminal Services). While the core of Remote Desktop is present in Windows 10 Home, and indeed is used to implement fast user switching and Remote Assistance (now called "Quick Assist"), various features of it have been disabled, including the removal of the command line utilities such as query.exe
. By contrast, higher Windows 10 editions including Pro do include those command line utilities.
However, since the underlying APIs are still present, the command line utilities do actually work on Windows 10 Home if you copy them from a Windows 10 Pro (or higher) machine.
I have two machines, one runs Windows 10 Pro and the other runs Windows 10 Home. Both running build 2004. I can successfully get query.exe
to work on the Windows 10 Home machine by copying these four files from Windows 10 Pro:
C:\Windows\System32\query.exe
C:\Windows\System32\Query.dll
C:\Windows\System32\en-US\Query.dll.mui
C:\Windows\System32\en-US\query.exe.mui
You don't need to put them in C:\Windows\System32
on the Win10 Home machine. It is sufficient to put those the query.exe
and query.dll
files in any directory, and then put the two .mui
files in a en-US
subdirectory of that directory. (Note that the .mui
file path is correct for US English Windows, if you are using another language those files will come from another subdirectory than en-US
.)
After doing the above, running query.exe
fails with this error: Can't load QUERY commands from the registry (error 1).
To fix that, we need to do the following: reg export "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\Utilities\query" query.reg
on the Pro machine, and then reg import query.reg
on the Home machine. Now, query.exe
works.
But all query user
does is call quser.exe
, so query user
is not going to work on Win10 Home because you don't have quser.exe
– you can try copying that as well. Actually all query.exe
does is delegate to a bunch of other executables: quser.exe
, qappsrv.exe
, qprocess.exe
, qwinsta.exe
. For query.exe
to work, you need those EXEs, none of which are included in Win10 Home. You might as well just skip query.exe
and copy whichever underlying EXEs you actually need.
For example, if you copy C:\Windows\System32\quser.exe
and C:\Windows\System32\en-US\quser.exe.mui
to Win10 Home, quser.exe
works. You just have to make sure quser.exe.mui
is in an en-US
subdirectory of the directory containing quser.exe
. I haven't tried any of the other q
commands, but the others can likely be made to work using the same approach.
(Note while this technically works, I don't know whether it complies with Microsoft's licensing agreements. If you are concerned about that topic, do this at your own risk.)
Solution 2:
I have had the same problem using a Win10Home. I copied quser.exe from an Win10Pro machine. It works on my Win10Home too!