Given Windows DOS command input:

tasklist|find /i "explorer.exe"

How to pass it to RunProcess or similar function and get the output?


1 Answer 1


RunProcess does not run shell commands (things you might type into your terminal). It runs processes, as the name suggests.

If you want to run shell commands, then you have these options:

  • Run (it does not give you the output)
  • Import["!yourcommand", "String"] or similar (to get the output)
  • Run your shell with RunProcess/StartProcess and pass the commands to it on its standard input. StartProcess has an example like this.
  • For this specific task, run cmd.exe with the /c flag and tell it what to execute. RunProcess has an example like this.
  • $\begingroup$ Thanks! but why RunProcess[{"cmd", "/c", " tasklist | find /i \"explorer.exe\""}] does not work? $\endgroup$
    – Jerry
    Nov 22, 2018 at 10:00
  • 1
    $\begingroup$ Import["! tasklist | find /i \"explorer.exe\"", "String"] works! ;) $\endgroup$
    – Jerry
    Nov 22, 2018 at 10:02
  • $\begingroup$ @Jerry I don't know how to get the quoting right. I do not use Windows. $\endgroup$
    – Szabolcs
    Nov 22, 2018 at 10:12
  • 2
    $\begingroup$ It's already solved using Import, thanks for help! $\endgroup$
    – Jerry
    Nov 22, 2018 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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