wmic output hangs when using psexec

I recently found when trying to issue a wmic query on a remote system with psexec (1.98) it would hang and not display results.
The solution is to redirect STDIN to NUL.

psexec computer cmd /c "wmic path win32_usbcontroller < NUL:"

I found this solution on Sysinternals forums from June 2011.

3 thoughts on “wmic output hangs when using psexec

  1. vijay

    Hi , i am using PSExec to run some process on remote system,
    but when i run it ,it is working but the GUI of that process is hanged,
    I tried it with Calc,it is also showing black screen on Remote system.
    Please let me know if you can do some thing

    Reply
    1. Rich Kreider Post author

      You could use something like

      tasklist /s REMOTECOMPUTER /v | find /I calc.exe

      When you have the PID, you can then just kill the process from the remote computer using:

      taskkill /s REMOTECOMPUTER /F /FI PID eq #PID#

      Or if you are certain it’s not going to affect anyone else on remote system, you can terminate tasks based on image name:

      taskkill /s REMOTECOMPUTER /F /IM calc.exe
      Reply
  2. vijay

    Hi Rich Thanks for Reply,
    I think i have not explained my self properly,
    i want to start a task on Remote computer ,i am using PSExec command for that as follow
    psexec RemoteComputer -i 1 -d “calc”
    it is stating a process on remote system,but when i check on remote system the GUI window for Calc is complety black. nothing is being show on remote system.
    i want to show the process correctly with their proper output.means complete GUI Windows
    Please help

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *