Is it possible to use the standard library to spawn a process without showing the console window in Windows?

邮差的信 提交于 2020-03-25 19:25:27

问题


This is what I have right now:

Command::new("/path/to/application")
  .args("-param")
  .spawn()

It looks like Rust uses CreateProcessW for running Windows processes, which allows creation flags. Perhaps there is a flag which will do what I need?


回答1:


std:os::windows::process::CommandExt extends the process::Command builder with windows-specific options when building for windows. Though no constant is defined for CREATE_NO_WINDOW so you'd either need to define it yourself or use the raw value of 0x08000000

e.g.

let command Command::new("my-command").args("param").creation_flags(0x08000000).spawn();


来源:https://stackoverflow.com/questions/59692146/is-it-possible-to-use-the-standard-library-to-spawn-a-process-without-showing-th

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!