ProcessStartInfo.CreateNoWindow Egenskap
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Hämtar eller anger ett värde som anger om processen ska startas i ett nytt fönster.
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
Egenskapsvärde
trueom processen ska startas utan att skapa ett nytt fönster som ska innehålla den; annars . false Standardvärdet är false.
Exempel
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
Kommentarer
Om egenskapen UseShellExecute är true eller UserName egenskaperna och Password inte nullär det CreateNoWindow ignoreras egenskapsvärdet och ett nytt fönster skapas.
.NET Core stöder inte att skapa fönster direkt på Unix-liknande plattformar, inklusive macOS och Linux. Den här egenskapen ignoreras på sådana plattformar.