Reputation: 41
The rust std::process::Command
; structure take in a Command::new(program)
, where program is the path to the program to be executed as shown in the example below.
let output = if cfg!(target_os = "windows") {
Command::new("cmd")
.args(&["/C", "echo hello"])
.output()
.expect("failed to execute process")
Is it possible to create a new process on windows in rust to run a function?
Upvotes: 4
Views: 2178
Reputation: 1993
In short, you cannot, creating a new process needs much more information than just the code it will execute. See CreateProcess Windows' system call.
But, you can choose between these alternatives:
Upvotes: 1