.NET Framework Class Library
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)
Syntax

Visual Basic (Declaration)
Public Property CreateNoWindow As Boolean
Visual Basic (Usage)
Dim instance As ProcessStartInfo
Dim value As Boolean

value = instance.CreateNoWindow

instance.CreateNoWindow = value
C#
public bool CreateNoWindow { get; set; }
Visual C++
public:
property bool CreateNoWindow {
    bool get ();
    void set (bool value);
}
JScript
public function get CreateNoWindow () : boolean
public function set CreateNoWindow (value : boolean)

Property Value

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

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

Examples

Visual Basic
Imports System
Imports System.Diagnostics
Imports System.ComponentModel


Namespace MyProcessSample

    Class MyProcess

        Public Shared Sub Main()
            Dim myProcess As New Process()

            Try                ' Get the path that stores user documents.

                myProcess.StartInfo.UseShellExecute = False
                ' You can start any process, HelloWorld is a do-nothing example.
                myProcess.StartInfo.FileName = "C:\\HelloWorld.exe"
                myProcess.StartInfo.CreateNoWindow = True
                myProcess.Start()
                ' This code assumes the process you are starting will terminate itself. 
                ' Given that is is started without a window so you cannot terminate it 
                ' on the desktop, it must terminate itself or you can do it programmatically
                ' from this application using the Kill method.
            Catch e As Exception
                Console.WriteLine((e.Message))
            End Try
        End Sub 'Main
    End Class
End Namespace
C#
using System;
using System.Diagnostics;
using System.ComponentModel;

namespace MyProcessSample
{
    class MyProcess
    {
        public static void Main()
        {
            Process myProcess = new Process();

            try
            {
                myProcess.StartInfo.UseShellExecute = false;
                // You can start any process, HelloWorld is a do-nothing example.
                myProcess.StartInfo.FileName = "C:\\HelloWorld.exe";
                myProcess.StartInfo.CreateNoWindow = true;
                myProcess.Start();
                // This code assumes the process you are starting will terminate itself. 
                // Given that is is started without a window so you cannot terminate it 
                // on the desktop, it must terminate itself or you can do it programmatically
                // from this application using the Kill method.
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
    }
}
Visual C++
#using <System.dll>
using namespace System;
using namespace System::Diagnostics;
using namespace System::ComponentModel;

int main()
{
    Process^ myProcess = gcnew Process;
    try
    {

        // Get the path that stores user documents.
        String^ myDocumentsPath = Environment::GetFolderPath( Environment::SpecialFolder::Personal );
        // You can start any process, HelloWorld is a do-nothing example.
        myProcess->StartInfo->FileName = "C:\\MyFile.doc";
        myProcess->StartInfo->UseShellExecute = false;
        myProcess->StartInfo->CreateNoWindow = true;
        myProcess->Start();
        // This code assumes the process you are starting will terminate itself. 
        // Given that is is started without a window so you cannot terminate it 
        // on the desktop, it must terminate itself or you can do it programmatically
        // from this application using the Kill method.
    }
    catch ( Exception^ e ) 
    {
        Console::WriteLine( e->Message );
    }
}

Platforms

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

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
See Also

Reference

Tags :


Community Content

Goatflats
UseShellExecute vs. CreateNoWindow
If the UseShellExecute property is set to true, the CreateNoWindow property value is ignored and a new window is created.
Tags :

JN2
Negative logic
Gotta love this property, I'm not very smart so I had to double check using MSDN.

Next time please call it CreateWindow...

http://blogs.msdn.com/oldnewthing/archive/2007/03/14/1878777.aspx

/Jonas
Tags : logic negative

Page view tracker