2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -181,6 +181,13 @@ pub trait CommandExt: Sealed {
181
181
#[ stable( feature = "windows_process_extensions" , since = "1.16.0" ) ]
182
182
fn creation_flags ( & mut self , flags : u32 ) -> & mut process:: Command ;
183
183
184
+ /// Sets the field [wShowWindow][1] of [STARTUPINFO][2] that is passed to `CreateProcess`.
185
+ ///
186
+ /// [1]: https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showwindow
187
+ /// [2]: https://learn.microsoft.com/es-es/windows/win32/api/processthreadsapi/ns-processthreadsapi-startupinfow
188
+ #[ unstable( feature = "windows_process_extensions_show_window" , issue = "none" ) ]
189
+ fn show_window ( & mut self , cmd_show : u16 ) -> & mut process:: Command ;
190
+
184
191
/// Forces all arguments to be wrapped in quote (`"`) characters.
185
192
///
186
193
/// This is useful for passing arguments to [MSYS2/Cygwin][1] based
@@ -370,6 +377,11 @@ impl CommandExt for process::Command {
370
377
self
371
378
}
372
379
380
+ fn show_window ( & mut self , cmd_show : u16 ) -> & mut process:: Command {
381
+ self . as_inner_mut ( ) . show_window ( Some ( cmd_show) ) ;
382
+ self
383
+ }
384
+
373
385
fn force_quotes ( & mut self , enabled : bool ) -> & mut process:: Command {
374
386
self . as_inner_mut ( ) . force_quotes ( enabled) ;
375
387
self
Original file line number Diff line number Diff line change @@ -163,6 +163,7 @@ pub struct Command {
163
163
env : CommandEnv ,
164
164
cwd : Option < OsString > ,
165
165
flags : u32 ,
166
+ show_window : Option < u16 > ,
166
167
detach : bool , // not currently exposed in std::process
167
168
stdin : Option < Stdio > ,
168
169
stdout : Option < Stdio > ,
@@ -194,6 +195,7 @@ impl Command {
194
195
env : Default :: default ( ) ,
195
196
cwd : None ,
196
197
flags : 0 ,
198
+ show_window : None ,
197
199
detach : false ,
198
200
stdin : None ,
199
201
stdout : None ,
@@ -224,6 +226,9 @@ impl Command {
224
226
pub fn creation_flags ( & mut self , flags : u32 ) {
225
227
self . flags = flags;
226
228
}
229
+ pub fn show_window ( & mut self , cmd_show : Option < u16 > ) {
230
+ self . show_window = cmd_show;
231
+ }
227
232
228
233
pub fn force_quotes ( & mut self , enabled : bool ) {
229
234
self . force_quotes_enabled = enabled;
@@ -337,6 +342,11 @@ impl Command {
337
342
si. hStdError = stderr. as_raw_handle ( ) ;
338
343
}
339
344
345
+ if let Some ( cmd_show) = self . show_window {
346
+ si. dwFlags |= c:: STARTF_USESHOWWINDOW ;
347
+ si. wShowWindow = cmd_show;
348
+ }
349
+
340
350
let si_ptr: * mut c:: STARTUPINFOW ;
341
351
342
352
let mut proc_thread_attribute_list;
0 commit comments