.NET - WindowStyle hidden vs. CreateNoWindow true?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
ProcessStartInfo.WindowStyle = Hidden and ProcessStartInfo.CreateNoWindow = true sound similar, but they are not the same setting. One asks for a window to start hidden if a window exists, and the other asks the process to start without creating a console window at all. Understanding that difference makes process-launch behavior much more predictable.
What WindowStyle = Hidden Means
WindowStyle is about the state of a window when the process starts. If you set it to ProcessWindowStyle.Hidden, you are saying, in effect, "if this process creates a window, start that window hidden."
This makes sense for applications that normally create a visible window. It does not mean the process is running headless. It means the window is hidden.
What CreateNoWindow = true Means
CreateNoWindow is aimed at console-style processes. It tells the operating system not to create a new console window for the child process.
This is useful for background command-line work such as scripts, command invocations, and automation tasks where a console popup would be annoying.
The important condition is UseShellExecute = false. If shell execution is enabled, CreateNoWindow is ignored.
They Solve Different Problems
A quick way to think about it:
- '
WindowStyle.Hiddenis about window state' - '
CreateNoWindowis about console creation'
For a GUI app, WindowStyle.Hidden is the more relevant setting. For a console command launched in the background, CreateNoWindow = true is usually the more relevant one.
You can combine them:
But in many console scenarios, CreateNoWindow is the setting that actually matters.
UseShellExecute Changes the Behavior
This is where many misunderstandings come from. UseShellExecute controls whether Windows launches the process through the shell. When it is true, several process-start options behave differently, and CreateNoWindow does not do what many people expect.
A common background-task setup looks like this:
This pattern is common because redirected streams also require UseShellExecute = false.
GUI Applications Still Have Their Own Rules
If you launch a real GUI application, CreateNoWindow does not magically turn it into a non-visual process. A GUI app can still create and manage its own windows. WindowStyle.Hidden is the property that more directly expresses "start hidden" for GUI scenarios.
Even then, the target application may not honor the request in every case. The launched program still controls its own UI behavior once running.
Choose the Setting Based on the Target Process
Use WindowStyle.Hidden when:
- the target process is a GUI application
- you want the window hidden rather than absent
- shell-style launching is acceptable
Use CreateNoWindow = true when:
- the target process is a console program
- you do not want a console window to appear
- you are already using
UseShellExecute = false
That distinction covers most real-world cases.
Common Pitfalls
The biggest mistake is expecting CreateNoWindow = true to hide any kind of application window, including GUI windows. Another common issue is forgetting that CreateNoWindow is ignored when UseShellExecute is true. Developers also sometimes set both options without understanding which one is actually affecting the observed behavior. Finally, even WindowStyle.Hidden is still only a start request; the child process may later show UI on its own depending on how it is written.
Summary
- '
WindowStyle.Hiddenasks a process window to start hidden.' - '
CreateNoWindow = trueprevents creation of a new console window for console-style processes.' - '
CreateNoWindowonly works as expected whenUseShellExecute = false.' - GUI apps and console apps respond to these settings differently.
- Pick the setting based on the kind of process you are launching, not just on the words "hidden" and "no window."
Related reading
- .NET 4.0 build issues on CI server
- .NET 4.0 has a new GAC, why?
- .NET / C - Convert char to string
- .NET async webservice call with a callback
- .NET asyncawait fundamentals
- .NET Asynchronous sockets vs backgroundworker
- .NET Caching how does Sliding Expiration work?
- .NET Config Files configSource outside the application directory folder

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.