# RunProcess seemingly does not work on my Windows system [closed]

System: Windows 10 professional. Mathematica Version: 10.3.0 English.

RunProcess doesn't work in my computer as described in tutorial.

The right result the function should give:

I tried different RunProcess examples given in the documentation and it seems that most of them work on Windows not as expected. For instance:

RunProcess[$SystemShell, All, "echo example line 1 echo example line 2 exit "]  Outcome as follows: <|"ExitCode" -> 0, "StandardOutput" -> "Microsoft Windows [\[Degree]æ\[PlusMinus]¾ 10.0.10586] (c) 2015 Microsoft Corporation¡£\[PlusMinus]Some text... C:\Users\Veya\Documents>echo example line 1 example line 1 C:\Users\Veya\Documents>echo example line 2 example line 2 C:\Users\Veya\Documents>exit ", "StandardError" -> ""|>  And it should be shorter: <|"ExitCode" -> 0, "StandardOutput" -> "example line 1 example line 2 ", "StandardError" -> ""|>  Question: What am I doing wrong? Are problems due to my Windows settings? How can I get results looking as described in the documentation? Why I need RunProcess I want to use MaTex in Mathematica; it is based on RunProcess. Addition: I've also directly tried Environment command from documentation but get $Failed.

 Environment["HOME"]
> $Failed  • Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! Nov 27, 2015 at 13:00 • Thank you for your advice. I will keep it in mind. Nov 28, 2015 at 16:09 • @Veya, did you see possible issues in documentation? i.e. optionC = If[StringFreeQ[$System, "Windows"], "-c", "/c"]; RunProcess[{$SystemShell, optionC, "echo example line"}] Nov 28, 2015 at 20:50 • @garej I have tried your code in my computer and get a result like this:<|"ExitCode" -> 0, "StandardOutput" -> "example line ", "StandardError" -> ""|> It seems like a right result. But I don't know what it means? Nov 29, 2015 at 2:40 • @garel I have tracked clew into function named Environment. This code didn't work either.(Input Environment["HOME"] Output $Failed) Maybe it is the source of problem. But I also don't know how to fix it. Nov 29, 2015 at 10:09

Your RunProcess works properly in all examples and System settings are fine. As @Oleksandr R. has admitted, date is a shell builtin on Windows. So there are commands date /t and time /t in cmd Windows shell that can be used instead.

In Mathematica for Windows:

$SystemShell == "cmd" (* True *)  So something like: RunProcess[{"cmd", "/c", "date /t&&time /t"}]  gives <|"ExitCode" -> 0, "StandardOutput" -> "30.11.2015 23:17 ", "StandardError" -> ""|>  Compare: Your code from documentation RunProcess[$SystemShell, All, "echo example line 1
echo example line 2
exit
"]


also gave you the right output (as it looks in Windows cmd shell). Just compare your output with the screen:

(I've used Win+R and cmd /k cls to avoid information about OS.)

If you want to avoid intermediate lines from shell that seem puzzled you, try something similar to this:

RunProcess[{"cmd", "/k",
"cls&&echo example line 1&&echo example line 2&&exit"}]


or this (note, that key /k needs exit to stop RunProcess):

RunProcess[{"cmd", "/c",
"cls&&echo example line 1&&echo example line 2"}]

<|"ExitCode" -> 0, "StandardOutput" -> "

example line 1

example line 2

", "StandardError" -> ""|>


Environment["HOMEPATH"]

\Users\Acer

Note that RunProcess[{'*command*', ...}] in the command place expects binary file which is visible (by explicit path or Environment). To see all Environment variables one may use
First /@ GetEnvironment[]

• Good answer; +1. However, I just wanted to make it explicit: OP's first example didn't work because date is a shell builtin on Windows. I'm sure you know this, but it is not mentioned anywhere in the comments or answer, so I include it here for completeness. Nov 30, 2015 at 23:28