0

Rust – How to run Windows bat or cmd file

In Rust, we can use  std::process::Command  to run a .bat  or .cmd  file in Windows.

Sample .bat  or .cmd  File

Codes

First we make std::process::Command available in the codes. Alternatively, we could directly reference it.

Next, we invoke echotest.bat

Lastly, we display the console output.

Output

Tested with Rust 1.37.0 on Windows 10.

For more information

Karl San Gabriel

Karl San Gabriel

Professional Software Developer