process - 尝试从 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
解决方案
当删除转义引号(我设置它们是在 cmd.exe 中启动进程所需的)时,它可以工作。
推荐阅读
- matplotlib - 当 x 值的间距不均匀时,如何避免 plt.bar 中的重叠条?
- android - 当我最小化我的应用程序并重新打开它时,调整布局大小
- android - Android Gradle如何按产品风格自定义库中的sourceSet?
- karate - 在空手道中,我可以自动更新请求负载(JSON 格式)中的一个字段的值吗?
- c - 将 Fortran 整数值分配给 malloc 分配的 C 内存目标
- mysql - 如何将查询字符串用于 knex?
- python - 截断“空格”问题 x/002
- acumatica - 在销售价格网格中添加 subitemID 列,但出现错误
- sql - 在 SQL 中从一段时间内的累计总数中查找销售增长
- azure - 等同于使用 Azure blob 存储的基于 S3 浏览器的 POST 策略?