![]() ![]() Windows currently offers no direct mechanism for that launching a console application invariably creates a visible console for it. However, your question's title might lead people to think your intent is to run the batch file itself - or any console application - invisibly: If you want to see the program's output in the current console window - albeit without being able to capture it - use -NoNewWindow, which, however, only makes sense if you also use -Wait, otherwise the asynchronously running program's output will interfere with your display (and if you're waiting anyway, direct, synchronous invocation is the better option).Īs an aside: on Unix-like platforms, -WindowStyle isn't supported, and -NoNewWindow is implied, which mostly makes Start-Process only useful for launching GUI programs on Unix (including launching URLs in order to open them in the default web browser e.g. RedirectStandardOutput and -RedirectStandardError parameters also, in order to check the exit code you need to use -PassThru so as to obtain an object that represents the newly launched process. WindowStyle Hidden hides this new window note that you won't be able to see or capture any output, unless you request redirection to files via the What you wanted is to hide the console window that by default results from PowerShell's Start-Process launching a console application (which isn't normally done, because direct, synchronous execution is by far the most common use case - see this answer): Powershell.exe -c "if (-not ($ps = Start-Process -WindowStyle Hidden myapp.exe -PassThru).WaitForExit(60000)) " ![]() To hide only the console window that results from use of Start-Process with a console application ( myapp.exe in your case), use -WindowStyle Hidden, as shown in your answer, but you can also streamline and shorten your code by performing all operations in a single powershell.exe call: off
0 Comments
Leave a Reply. |