Freigeben über


ProcessStartInfo.CreateNoWindow Eigenschaft

Definition

Dient zum Abrufen oder Festlegen eines Werts, der angibt, ob der Prozess in einem neuen Fenster gestartet werden soll.

public:
 property bool CreateNoWindow { bool get(); void set(bool value); };
public bool CreateNoWindow { get; set; }
member this.CreateNoWindow : bool with get, set
Public Property CreateNoWindow As Boolean

Eigenschaftswert

truewenn der Prozess gestartet werden soll, ohne ein neues Fenster zu erstellen, das es enthalten soll; andernfalls . false Der Standardwert lautet false.

Beispiele

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

namespace MyProcessSample
{
    class MyProcess
    {
        public static void Main()
        {
            try
            {
                using (Process myProcess = new Process())
                {
                    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 it 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);
            }
        }
    }
}
Imports System.Diagnostics
Imports System.ComponentModel

Namespace MyProcessSample
    Class MyProcess
        Public Shared Sub Main()
            Try
                Using myProcess As New Process()

                    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 it 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.
                End Using
            Catch e As Exception
                Console.WriteLine((e.Message))
            End Try
        End Sub
    End Class
End Namespace

Hinweise

Wenn die UseShellExecute Eigenschaft oder die UserNamePassword Eigenschaften nicht nullvorhanden sindtrue, wird der CreateNoWindow Eigenschaftswert ignoriert und ein neues Fenster erstellt.

.NET Core unterstützt das Erstellen von Fenstern nicht direkt auf Unix-ähnlichen Plattformen, einschließlich macOS und Linux. Diese Eigenschaft wird auf solchen Plattformen ignoriert.

Gilt für: