CreateNoWindow Property

ProcessStartInfo.CreateNoWindow Property

Gets or sets a value indicating whether to start the process in a new window.

Namespace: System.Diagnostics
Assembly: System (in system.dll)

public bool CreateNoWindow { get; set; }
/** @property */
public boolean get_CreateNoWindow ()

/** @property */
public void set_CreateNoWindow (boolean value)

public function get CreateNoWindow () : boolean

public function set CreateNoWindow (value : boolean)

Not applicable.

Property Value

true to start the process without creating a new window to contain it; otherwise, false. The default is false.

If the UserName and Password properties are not a null reference (Nothing in Visual Basic), the CreateNoWindow property value is ignored and a new window is created.

using System;
using System.Diagnostics;
using System.ComponentModel;

namespace MyProcessSample
	/// <summary>
	/// Shell for the sample.
	/// </summary>
	class MyProcess
		// These are the Win32 error code for file not found or access denied.
		const int ERROR_FILE_NOT_FOUND =2;
		const int ERROR_ACCESS_DENIED = 5;

		/// <summary>
		/// Prints a file with a .doc extension.
		/// </summary>
		void PrintDoc()
			Process myProcess = new Process();
				// Get the path that stores user documents.
				string myDocumentsPath = 

				myProcess.StartInfo.FileName = myDocumentsPath + "\\MyFile.doc"; 
				myProcess.StartInfo.Verb = "Print";
				myProcess.StartInfo.CreateNoWindow = true;
			catch (Win32Exception e)
				if(e.NativeErrorCode == ERROR_FILE_NOT_FOUND)
					Console.WriteLine(e.Message + ". Check the path.");

				else if (e.NativeErrorCode == ERROR_ACCESS_DENIED)
					// Note that if your word processor might generate exceptions
					// such as this, which are handled first.
					Console.WriteLine(e.Message + 
						". You do not have permission to print this file.");

		public static void Main()
			MyProcess myProcess = new MyProcess();

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

© 2016 Microsoft