首页 > 解决方案 > 尝试从 Rust 启动另一个可执行文件时权限被拒绝错误

问题描述

我正在尝试在 Rust 中启动一个子进程。它是另一个可执行文件。

最小代码如下所示:

use std::process::{Command, Stdio};

fn main() {
    let mut child = Command::new("\"./target/release/path_to_binary.exe\"")
        .stdin(Stdio::piped())
        .stdout(Stdio::piped())
        .output()
        .expect("Failed to execute command!");
}

我收到以下错误:

thread 'main' panicked at 'Failed to execute command!: Os { code: 5, kind: Permi
ssionDenied, message: "Zugriff verweigert" }', src\libcore\result.rs:997:5

标签: processrust

解决方案


当删除转义引号(我设置它们是在 cmd.exe 中启动进程所需的)时,它可以工作。


推荐阅读