I wanted to run this particular command. When I ran it as a batch script for Windows:
powershell -command "&{Start-Process -filepath 'cmd' -argumentlist '/c cmd.exe' -verb runas}"
It runs just fine. But when I tried to do the same thing for Rust:
use std::process::Command;
fn main()
{
// powershell -command "&{Start-Process -filepath 'cmd' -argumentlist '/c cmd.exe' -verb runas}"
let test = Command::new("cmd.exe")
.arg("/c")
.arg("powershell")
.arg(r#"-command "&{Start-Process -filepath 'cmd' -argumentlist '/c cmd.exe' -verb runas}""#)
.output()
.unwrap();
println!("{:?}", test);
}
It fails and I get this stderr
.
Output { status: ExitStatus(ExitStatus(1)), stdout: "", stderr: "The string is missing the terminator: \".\r\n + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException\r\n + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString\r\n \r\n\'{Start-Process\' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n" }
Any idea how to solve this?