Preventing Flashing Console Window

by Aug 14, 2013

When you run a console command inside a non-console PowerShell host (like the ISE editor), there will be a flashing window, indicating that the host is launching a temporary console window to host the console command.

That's no bad thing, but if you must prevent this, you can always run the console command in a second process with a hidden window.

This line runs tzutil.exe to set the current time zone, and it does so by launching a second hidden console window:

Start-Process -FilePath tzutil.exe -ArgumentList '/s "W. Europe Standard Time"' -WindowStyle Hidden

Caution: when you run this line, your current time zone will be set to European Standard Time.

There is generally almost no need anymore to use the low-level .NET System.Diagnostics.Process class to run hidden processes because Start-Process has all the options and parameters you possibly want.

Twitter This Tip! ReTweet this Tip!