.NET Framework Class Library Process Class Provides access to local and remote processes and enables you to start and stop local system processes.

Inheritance Hierarchy
Namespace:
System.Diagnostics
Assembly:
System (in System.dll)

Syntax
<PermissionSetAttribute(SecurityAction.InheritanceDemand, Name := "FullTrust")> _
<HostProtectionAttribute(SecurityAction.LinkDemand, SharedState := True, Synchronization := True, _
ExternalProcessMgmt := True, SelfAffectingProcessMgmt := True)> _
<PermissionSetAttribute(SecurityAction.LinkDemand, Name := "FullTrust")> _
Public Class Process _
Inherits Component
[PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")]
[HostProtectionAttribute(SecurityAction.LinkDemand, SharedState = true, Synchronization = true,
ExternalProcessMgmt = true, SelfAffectingProcessMgmt = true)]
[PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")]
public class Process : Component
[PermissionSetAttribute(SecurityAction::InheritanceDemand, Name = L"FullTrust")]
[HostProtectionAttribute(SecurityAction::LinkDemand, SharedState = true, Synchronization = true,
ExternalProcessMgmt = true, SelfAffectingProcessMgmt = true)]
[PermissionSetAttribute(SecurityAction::LinkDemand, Name = L"FullTrust")]
public ref class Process : public Component
[<PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")>]
[<HostProtectionAttribute(SecurityAction.LinkDemand, SharedState = true, Synchronization = true,
ExternalProcessMgmt = true, SelfAffectingProcessMgmt = true)>]
[<PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")>]
type Process =
class
inherit Component
end
The Process type exposes the following members.

Constructors
|
| Name | Description |
|---|
.gif) | Process | Initializes a new instance of the Process class. | Top

Methods
|
| Name | Description |
|---|
.gif) | BeginErrorReadLine | Begins asynchronous read operations on the redirected StandardError stream of the application. | .gif) | BeginOutputReadLine | Begins asynchronous read operations on the redirected StandardOutput stream of the application. | .gif) | CancelErrorRead | Cancels the asynchronous read operation on the redirected StandardError stream of an application. | .gif) | CancelOutputRead | Cancels the asynchronous read operation on the redirected StandardOutput stream of an application. | .gif) | Close | Frees all the resources that are associated with this component. | .gif) | CloseMainWindow | Closes a process that has a user interface by sending a close message to its main window. | .gif) | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.) | .gif) | Dispose()()() | Releases all resources used by the Component. (Inherited from Component.) | .gif) | Dispose(Boolean) | Infrastructure. Release all resources used by this process. (Overrides Component..::.Dispose(Boolean).) | .gif) .gif) | EnterDebugMode | Puts a Process component in state to interact with operating system processes that run in a special mode by enabling the native property SeDebugPrivilege on the current thread. | .gif) | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | .gif) | Finalize | Releases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection. (Inherited from Component.) | .gif) .gif) | GetCurrentProcess | Gets a new Process component and associates it with the currently active process. | .gif) | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | .gif) | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.) | .gif) .gif) | GetProcessById(Int32) | Returns a new Process component, given the identifier of a process on the local computer. | .gif) .gif) | GetProcessById(Int32, String) | Returns a new Process component, given a process identifier and the name of a computer on the network. | .gif) .gif) | GetProcesses()()() | Creates a new Process component for each process resource on the local computer. | .gif) .gif) | GetProcesses(String) | Creates a new Process component for each process resource on the specified computer. | .gif) .gif) | GetProcessesByName(String) | Creates an array of new Process components and associates them with all the process resources on the local computer that share the specified process name. | .gif) .gif) | GetProcessesByName(String, String) | Creates an array of new Process components and associates them with all the process resources on a remote computer that share the specified process name. | .gif) | GetService | Returns an object that represents a service provided by the Component or by its Container. (Inherited from Component.) | .gif) | GetType | Gets the Type of the current instance. (Inherited from Object.) | .gif) | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.) | .gif) | Kill | Immediately stops the associated process. | .gif) .gif) | LeaveDebugMode | Takes a Process component out of the state that lets it interact with operating system processes that run in a special mode. | .gif) | MemberwiseClone()()() | Creates a shallow copy of the current Object. (Inherited from Object.) | .gif) | MemberwiseClone(Boolean) | Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.) | .gif) | OnExited | Raises the Exited event. | .gif) | Refresh | Discards any information about the associated process that has been cached inside the process component. | .gif) | Start()()() | Starts (or reuses) the process resource that is specified by the StartInfo property of this Process component and associates it with the component. | .gif) .gif) | Start(ProcessStartInfo) | Starts the process resource that is specified by the parameter containing process start information (for example, the file name of the process to start) and associates the resource with a new Process component. | .gif) .gif) | Start(String) | Starts a process resource by specifying the name of a document or application file and associates the resource with a new Process component. | .gif) .gif) | Start(String, String) | Starts a process resource by specifying the name of an application and a set of command-line arguments, and associates the resource with a new Process component. | .gif) .gif) | Start(String, String, SecureString, String) | Starts a process resource by specifying the name of an application, a user name, a password, and a domain and associates the resource with a new Process component. | .gif) .gif) | Start(String, String, String, SecureString, String) | Starts a process resource by specifying the name of an application, a set of command-line arguments, a user name, a password, and a domain and associates the resource with a new Process component. | .gif) | ToString | Formats the process's name as a string, combined with the parent component type, if applicable. (Overrides Component..::.ToString()()().) | .gif) | WaitForExit()()() | Instructs the Process component to wait indefinitely for the associated process to exit. | .gif) | WaitForExit(Int32) | Instructs the Process component to wait the specified number of milliseconds for the associated process to exit. | .gif) | WaitForInputIdle()()() | Causes the Process component to wait indefinitely for the associated process to enter an idle state. This overload applies only to processes with a user interface and, therefore, a message loop. | .gif) | WaitForInputIdle(Int32) | Causes the Process component to wait the specified number of milliseconds for the associated process to enter an idle state. This overload applies only to processes with a user interface and, therefore, a message loop. | Top

Events

Remarks
Note |
|---|
Starting with the .NET Framework version 2.0, the ability to reference performance counter data on other computers has been eliminated for many of the .NET Framework methods and properties. This change was made to improve performance and to enable non-administrators to use the Process class. As a result, some applications that did not get exceptions in earlier versions of the .NET Framework may now get a NotSupportedException. The methods and properties affected are too numerous to list here, but the exception information has been added to the affected member topics. |
A Process component provides access to a process that is running on a computer. A process, in the simplest terms, is a running application. A thread is the basic unit to which the operating system allocates processor time. A thread can execute any part of the code of the process, including parts currently being executed by another thread. The Process component is a useful tool for starting, stopping, controlling, and monitoring applications. Using the Process component, you can obtain a list of the processes that are running, or you can start a new process. A Process component is used to access system processes. After a Process component has been initialized, it can be used to obtain information about the running process. Such information includes the set of threads, the loaded modules (.dll and .exe files), and performance information such as the amount of memory the process is using. If you have a path variable declared in your system using quotes, you must fully qualify that path when starting any process found in that location. Otherwise, the system will not find the path. For example, if c:\mypath is not in your path, and you add it using quotation marks: path = %path%;"c:\mypath", you must fully qualify any process in c:\mypath when starting it. The process component obtains information about a group of properties all at once. After the Process component has obtained information about one member of any group, it will cache the values for the other properties in that group and not obtain new information about the other members of the group until you call the Refresh method. Therefore, a property value is not guaranteed to be any newer than the last call to the Refresh method. The group breakdowns are operating-system dependent. A system process is uniquely identified on the system by its process identifier. Like many Windows resources, a process is also identified by its handle, which might not be unique on the computer. A handle is the generic term for an identifier of a resource. The operating system persists the process handle, which is accessed through the Handle property of the Process component, even when the process has exited. Thus, you can get the process's administrative information, such as the ExitCode (usually either zero for success or a nonzero error code) and the ExitTime. Handles are an extremely valuable resource, so leaking handles is more virulent than leaking memory. Note |
|---|
This class contains a link demand and an inheritance demand at the class level that applies to all members. A SecurityException is thrown when either the immediate caller or the derived class does not have full-trust permission. For details about security demands, see Link Demands and Inheritance Demands. |

Examples
The following example uses an instance of the Process class to start a process.
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
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);
}
}
}
}
#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 );
}
}
The following example uses the Process class itself and a static Start method to start a process.
Imports System
Imports System.Diagnostics
Imports System.ComponentModel
Namespace MyProcessSample
Class MyProcess
' Opens the Internet Explorer application.
Public Sub OpenApplication(myFavoritesPath As String)
' Start Internet Explorer. Defaults to the home page.
Process.Start("IExplore.exe")
' Display the contents of the favorites folder in the browser.
Process.Start(myFavoritesPath)
End Sub 'OpenApplication
' Opens urls and .html documents using Internet Explorer.
Sub OpenWithArguments()
' url's are not considered documents. They can only be opened
' by passing them as arguments.
Process.Start("IExplore.exe", "www.northwindtraders.com")
' Start a Web page using a browser associated with .html and .asp files.
Process.Start("IExplore.exe", "C:\myPath\myFile.htm")
Process.Start("IExplore.exe", "C:\myPath\myFile.asp")
End Sub 'OpenWithArguments
' Uses the ProcessStartInfo class to start new processes,
' both in a minimized mode.
Sub OpenWithStartInfo()
Dim startInfo As New ProcessStartInfo("IExplore.exe")
startInfo.WindowStyle = ProcessWindowStyle.Minimized
Process.Start(startInfo)
startInfo.Arguments = "www.northwindtraders.com"
Process.Start(startInfo)
End Sub 'OpenWithStartInfo
Shared Sub Main()
' Get the path that stores favorite links.
Dim myFavoritesPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Favorites)
Dim myProcess As New MyProcess()
myProcess.OpenApplication(myFavoritesPath)
myProcess.OpenWithArguments()
myProcess.OpenWithStartInfo()
End Sub 'Main
End Class 'MyProcess
End Namespace 'MyProcessSample
using System;
using System.Diagnostics;
using System.ComponentModel;
namespace MyProcessSample
{
class MyProcess
{
// Opens the Internet Explorer application.
void OpenApplication(string myFavoritesPath)
{
// Start Internet Explorer. Defaults to the home page.
Process.Start("IExplore.exe");
// Display the contents of the favorites folder in the browser.
Process.Start(myFavoritesPath);
}
// Opens urls and .html documents using Internet Explorer.
void OpenWithArguments()
{
// url's are not considered documents. They can only be opened
// by passing them as arguments.
Process.Start("IExplore.exe", "www.northwindtraders.com");
// Start a Web page using a browser associated with .html and .asp files.
Process.Start("IExplore.exe", "C:\\myPath\\myFile.htm");
Process.Start("IExplore.exe", "C:\\myPath\\myFile.asp");
}
// Uses the ProcessStartInfo class to start new processes,
// both in a minimized mode.
void OpenWithStartInfo()
{
ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
Process.Start(startInfo);
startInfo.Arguments = "www.northwindtraders.com";
Process.Start(startInfo);
}
static void Main()
{
// Get the path that stores favorite links.
string myFavoritesPath =
Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
MyProcess myProcess = new MyProcess();
myProcess.OpenApplication(myFavoritesPath);
myProcess.OpenWithArguments();
myProcess.OpenWithStartInfo();
}
}
}
#using <System.dll>
using namespace System;
using namespace System::Diagnostics;
using namespace System::ComponentModel;
// Opens the Internet Explorer application.
void OpenApplication( String^ myFavoritesPath )
{
// Start Internet Explorer. Defaults to the home page.
Process::Start( "IExplore.exe" );
// Display the contents of the favorites folder in the browser.
Process::Start( myFavoritesPath );
}
// Opens urls and .html documents using Internet Explorer.
void OpenWithArguments()
{
// url's are not considered documents. They can only be opened
// by passing them as arguments.
Process::Start( "IExplore.exe", "www.northwindtraders.com" );
// Start a Web page using a browser associated with .html and .asp files.
Process::Start( "IExplore.exe", "C:\\myPath\\myFile.htm" );
Process::Start( "IExplore.exe", "C:\\myPath\\myFile.asp" );
}
// Uses the ProcessStartInfo class to start new processes,
// both in a minimized mode.
void OpenWithStartInfo()
{
ProcessStartInfo^ startInfo = gcnew ProcessStartInfo( "IExplore.exe" );
startInfo->WindowStyle = ProcessWindowStyle::Minimized;
Process::Start( startInfo );
startInfo->Arguments = "www.northwindtraders.com";
Process::Start( startInfo );
}
int main()
{
// Get the path that stores favorite links.
String^ myFavoritesPath = Environment::GetFolderPath( Environment::SpecialFolder::Favorites );
OpenApplication( myFavoritesPath );
OpenWithArguments();
OpenWithStartInfo();
}

Version Information
.NET FrameworkSupported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0 .NET Framework Client ProfileSupported in: 4, 3.5 SP1

.NET Framework Security

Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Thread Safety
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also
|
.NET Framework-Klassenbibliothek Process-Klasse Ermöglicht den Zugriff auf lokale Prozesse und Remoteprozesse und das Starten und Anhalten lokaler Systemprozesse.

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

Syntax
<PermissionSetAttribute(SecurityAction.InheritanceDemand, Name := "FullTrust")> _
<HostProtectionAttribute(SecurityAction.LinkDemand, SharedState := True, Synchronization := True, _
ExternalProcessMgmt := True, SelfAffectingProcessMgmt := True)> _
<PermissionSetAttribute(SecurityAction.LinkDemand, Name := "FullTrust")> _
Public Class Process _
Inherits Component
[PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")]
[HostProtectionAttribute(SecurityAction.LinkDemand, SharedState = true, Synchronization = true,
ExternalProcessMgmt = true, SelfAffectingProcessMgmt = true)]
[PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")]
public class Process : Component
[PermissionSetAttribute(SecurityAction::InheritanceDemand, Name = L"FullTrust")]
[HostProtectionAttribute(SecurityAction::LinkDemand, SharedState = true, Synchronization = true,
ExternalProcessMgmt = true, SelfAffectingProcessMgmt = true)]
[PermissionSetAttribute(SecurityAction::LinkDemand, Name = L"FullTrust")]
public ref class Process : public Component
[<PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")>]
[<HostProtectionAttribute(SecurityAction.LinkDemand, SharedState = true, Synchronization = true,
ExternalProcessMgmt = true, SelfAffectingProcessMgmt = true)>]
[<PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")>]
type Process =
class
inherit Component
end
Der Process-Typ macht die folgenden Member verfügbar.

Konstruktoren

Eigenschaften
|
| Name | Beschreibung |
|---|
.gif) | BasePriority | Ruft die Basispriorität des zugeordneten Prozesses ab. | .gif) | CanRaiseEvents | Ruft einen Wert ab, der angibt, ob die Komponente ein Ereignis auslösen kann. (Von Component geerbt.) | .gif) | Container | Ruft den IContainer ab, der die Component enthält. (Von Component geerbt.) | .gif) | DesignMode | Ruft einen Wert ab, der angibt, ob sich Component gegenwärtig im Entwurfsmodus befindet. (Von Component geerbt.) | .gif) | EnableRaisingEvents | Ruft ab oder legt fest, ob beim Beenden des Prozesses das Exited-Ereignis ausgelöst werden soll. | .gif) | Events | Ruft die Liste der Ereignishandler ab, die dieser Component angefügt sind. (Von Component geerbt.) | .gif) | ExitCode | Ruft den Wert ab, der vom zugeordneten Prozess beim Beenden angegeben wurde. | .gif) | ExitTime | Ruft den Zeitpunkt ab, zu dem der zugeordnete Prozess beendet wurde. | .gif) | Handle | Ruft das systemeigene Handle des zugeordneten Prozesses ab. | .gif) | HandleCount | Ruft die Anzahl der vom Prozess geöffneten Handles ab. | .gif) | HasExited | Ruft einen Wert ab, der angibt, ob der zugehörige Prozess beendet wurde. | .gif) | Id | Ruft den eindeutigen Bezeichner für den zugeordneten Prozess ab. | .gif) | MachineName | Ruft den Namen des Computers ab, auf dem der zugeordnete Prozess ausgeführt wird. | .gif) | MainModule | Ruft das Hauptmodul für den zugeordneten Prozess ab. | .gif) | MainWindowHandle | Ruft das Fensterhandle des Hauptfensters des zugeordneten Prozesses ab. | .gif) | MainWindowTitle | Ruft die Beschriftung des Hauptfensters des Prozesses ab. | .gif) | MaxWorkingSet | Ruft die maximal zulässige Workingsetgröße für den zugeordneten Prozess ab oder legt diese fest. | .gif) | MinWorkingSet | Ruft die minimale zulässige Workingsetgröße für den zugeordneten Prozess ab oder legt diese fest. | .gif) | Modules | Ruft die Module ab, die vom zugeordneten Prozess geladen wurden. | .gif) | NonpagedSystemMemorySize | Veraltet. Ruft die Größe des nicht auslagerbaren Systemspeichers ab, der für diesen Prozess belegt wird. | .gif) | NonpagedSystemMemorySize64 | Ruft die Menge des für den zugeordneten Prozess belegten nicht ausgelagerten Systemspeichers ab. | .gif) | PagedMemorySize | Veraltet. Ruft die Größe des ausgelagerten Arbeitsspeichers ab. | .gif) | PagedMemorySize64 | Ruft die Größe des ausgelagerten Speichers ab, der für den zugeordneten Prozess belegt wird. | .gif) | PagedSystemMemorySize | Veraltet. Ruft die Größe des ausgelagerten Systemspeichers ab. | .gif) | PagedSystemMemorySize64 | Ruft die Menge des für den zugeordneten Prozess belegten auslagerbaren Systemspeichers ab. | .gif) | PeakPagedMemorySize | Veraltet. Ruft die maximale Größe des ausgelagerten Arbeitsspeichers ab. | .gif) | PeakPagedMemorySize64 | Ruft die vom zugeordneten Prozess verwendete maximale Speichergröße in der Auslagerungsdatei des virtuellen Arbeitsspeichers ab. | .gif) | PeakVirtualMemorySize | Veraltet. Ruft die maximale Größe des virtuellen Speichers ab. | .gif) | PeakVirtualMemorySize64 | Ruft die maximale Größe des virtuellen Speichers ab, der vom zugeordneten Prozess verwendet wird. | .gif) | PeakWorkingSet | Veraltet. Ruft die maximale Größe des Workingsets für den zugeordneten Prozess ab. | .gif) | PeakWorkingSet64 | Ruft die maximale Größe des physischen Speichers ab, der vom zugeordneten Prozess verwendet wird. | .gif) | PriorityBoostEnabled | Ruft einen Wert ab, der angibt, ob die zugeordnete Prozesspriorität durch das Betriebssystem vorübergehend erhöht werden soll, wenn das Hauptfenster den Fokus besitzt, oder legt diesen fest. | .gif) | PriorityClass | Ruft die allgemeine Prioritätskategorie für den zugeordneten Prozess ab oder legt diese fest. | .gif) | PrivateMemorySize | Veraltet. Ruft die Größe des privaten Speichers ab. | .gif) | PrivateMemorySize64 | Ruft die Größe des privaten Speichers ab, der für den zugeordneten Prozess belegt wird. | .gif) | PrivilegedProcessorTime | Ruft die privilegierte Prozessorzeit für diesen Prozess ab. | .gif) | ProcessName | Ruft den Namen des Prozesses ab. | .gif) | ProcessorAffinity | Ruft die Prozessoren ab, auf denen die Ausführung der Threads in diesem Prozess geplant werden kann, oder legt diese fest. | .gif) | Responding | Ruft einen Wert ab, der angibt, ob die Benutzeroberfläche des Prozesses reagiert. | .gif) | SessionId | Ruft die Terminaldienste-Sitzungs-ID für den zugeordneten Prozess ab. | .gif) | Site | Ruft die ISite der Component ab oder legt diese fest. (Von Component geerbt.) | .gif) | StandardError | Ruft einen Stream ab, mit dem die Fehlerausgabe der Anwendung gelesen wird. | .gif) | StandardInput | Ruft einen Stream ab, in den die Eingaben der Anwendung geschrieben werden. | .gif) | StandardOutput | Ruft einen Stream ab, mit dem die Ausgabe der Anwendung gelesen wird. | .gif) | StartInfo | Ruft die Eigenschaften ab, die an die Start-Methode von Process übergeben werden sollen, oder legt diese fest. | .gif) | StartTime | Ruft die Zeit ab, zu der der zugeordnete Prozess gestartet wurde. | .gif) | SynchronizingObject | Ruft das Objekt ab, das zum Marshallen der Ereignishandleraufrufe verwendet wird, die als Ergebnis eines Prozessbeendigungsereignisses ausgegeben werden, oder legt dieses fest. | .gif) | Threads | Ruft die Gruppe von Threads ab, die im zugeordneten Prozess ausgeführt werden. | .gif) | TotalProcessorTime | Ruft die gesamte Prozessorzeit für diesen Prozess ab. | .gif) | UserProcessorTime | Ruft die Benutzerprozessorzeit für diesen Prozess ab. | .gif) | VirtualMemorySize | Veraltet. Ruft die Größe des virtuellen Speichers für diesen Prozess ab. | .gif) | VirtualMemorySize64 | Ruft die Größe des virtuellen Speichers ab, der für den zugeordneten Prozess belegt wird. | .gif) | WorkingSet | Veraltet. Ruft die Auslastung des physischen Speichers durch den zugeordneten Prozess ab. | .gif) | WorkingSet64 | Ruft die Größe des physischen Speichers ab, der für den zugeordneten Prozess belegt wird. | Zum Seitenanfang

Methoden
|
| Name | Beschreibung |
|---|
.gif) | BeginErrorReadLine | Startet asynchrone Lesevorgänge im umgeleiteten StandardError-Stream der Anwendung. | .gif) | BeginOutputReadLine | Startet asynchrone Lesevorgänge im umgeleiteten StandardOutput-Stream der Anwendung. | .gif) | CancelErrorRead | Bricht den asynchronen Lesevorgang im umgeleiteten StandardError-Stream einer Anwendung ab. | .gif) | CancelOutputRead | Bricht den asynchronen Lesevorgang im umgeleiteten StandardOutput-Stream einer Anwendung ab. | .gif) | Close | Gibt alle dieser Komponente zugeordneten Ressourcen frei. | .gif) | CloseMainWindow | Schließt einen Prozess mit einer Benutzeroberfläche, indem eine Meldung zum Schließen an das Hauptfenster gesendet wird. | .gif) | CreateObjRef | Erstellt ein Objekt mit allen relevanten Informationen, die zum Generieren eines Proxys für die Kommunikation mit einem Remoteobjekt erforderlich sind. (Von MarshalByRefObject geerbt.) | .gif) | Dispose()()() | Gibt sämtliche von der Component verwendeten Ressourcen frei. (Von Component geerbt.) | .gif) | Dispose(Boolean) | Infrastruktur. Gibt alle von diesem Prozess verwendeten Ressourcen frei. (Überschreibt Component..::.Dispose(Boolean).) | .gif) .gif) | EnterDebugMode | Versetzt durch Aktivieren der systemeigenen SeDebugPrivilege-Eigenschaft für den aktuellen Thread eine Process-Komponente in einen Zustand, in dem sie mit Betriebssystemprozessen interagieren kann, die in einem speziellen Modus ausgeführt werden. | .gif) | Equals(Object) | Bestimmt, ob das angegebene Object und das aktuelle Object gleich sind. (Von Object geerbt.) | .gif) | Finalize | Gibt nicht verwaltete Ressourcen frei und führt andere Bereinigungsvorgänge durch, bevor die Component durch die Garbage Collection wieder zugänglich gemacht wird. (Von Component geerbt.) | .gif) .gif) | GetCurrentProcess | Ruft eine neue Process-Komponente ab und ordnet diese dem gegenwärtig aktiven Prozess zu. | .gif) | GetHashCode | Fungiert als Hashfunktion für einen bestimmten Typ. (Von Object geerbt.) | .gif) | GetLifetimeService | Ruft das aktuelle Lebensdauerdienstobjekt ab, das die Lebensdauerrichtlinien für diese Instanz steuert. (Von MarshalByRefObject geerbt.) | .gif) .gif) | GetProcessById(Int32) | Gibt eine neue Process-Komponente zurück, wenn der Bezeichner eines Prozesses auf dem lokalen Computer angegeben ist. | .gif) .gif) | GetProcessById(Int32, String) | Gibt eine neue Process-Komponente zurück, wenn die Prozess-ID und der Name des Computers im Netzwerk angegeben sind. | .gif) .gif) | GetProcesses()()() | Erstellt eine neue Process-Komponente für jede Prozessressource auf dem lokalen Computer. | .gif) .gif) | GetProcesses(String) | Erstellt eine neue Process-Komponente für jede Prozessressource auf dem angegebenen Computer. | .gif) .gif) | GetProcessesByName(String) | Erstellt ein Array neuer Process-Komponenten und ordnet diese allen Prozessressourcen auf dem lokalen Computer zu, die den angegebenen Prozessnamen gemeinsam verwenden. | .gif) .gif) | GetProcessesByName(String, String) | Erstellt ein Array neuer Process-Komponenten und ordnet diese allen Prozessressourcen auf einem Remotecomputer zu, die den angegebenen Prozessnamen gemeinsam verwenden. | .gif) | GetService | Gibt ein Objekt zurück, das einen von der Component oder von deren Container bereitgestellten Dienst darstellt. (Von Component geerbt.) | .gif) | GetType | Ruft den Type der aktuellen Instanz ab. (Von Object geerbt.) | .gif) | InitializeLifetimeService | Ruft ein Lebensdauerdienstobjekt ab, mit dem die Lebensdauerrichtlinien für diese Instanz gesteuert werden können. (Von MarshalByRefObject geerbt.) | .gif) | Kill | Hält den zugeordneten Prozess sofort an. | .gif) .gif) | LeaveDebugMode | Beendet den Zustand einer Process-Komponente, in dem sie mit Betriebssystemprozessen interagieren kann, die in einem speziellen Modus ausgeführt werden. | .gif) | MemberwiseClone()()() | Erstellt eine flache Kopie des aktuellen Object. (Von Object geerbt.) | .gif) | MemberwiseClone(Boolean) | Erstellt eine flache Kopie des aktuellen MarshalByRefObject-Objekts. (Von MarshalByRefObject geerbt.) | .gif) | OnExited | Löst das Exited-Ereignis aus. | .gif) | Refresh | Verwirft alle Informationen über den zugeordneten Prozess, die in der Prozesskomponente zwischengespeichert waren. | .gif) | Start()()() | Startet die von der StartInfo-Eigenschaft dieser Process-Komponente angegebene Prozessressource (oder verwendet sie erneut) und ordnet diese der Komponente zu. | .gif) .gif) | Start(ProcessStartInfo) | Startet die Prozessressource, die durch den Parameter mit den Startinformationen für den Prozess angegeben wird (z. B. den Dateinamen des zu startenden Prozesses), und ordnet die Ressource einer neuen Process-Komponente zu. | .gif) .gif) | Start(String) | Startet eine Prozessressource, indem der Name eines Dokuments oder einer Anwendungsdatei angegeben wird, und ordnet die Ressource einer neuen Process-Komponente zu. | .gif) .gif) | Start(String, String) | Startet eine Prozessressource durch Angeben des Namens einer Anwendung und einer Reihe von Befehlszeilenargumenten und ordnet die Ressource einer neuen Process-Komponente zu. | .gif) .gif) | Start(String, String, SecureString, String) | Startet eine Prozessressource durch Angeben des Namens einer Anwendung, eines Benutzernamens und einer Domäne und ordnet die Ressource einer neuen Process-Komponente zu. | .gif) .gif) | Start(String, String, String, SecureString, String) | Startet eine Prozessressource durch Angeben des Namens einer Anwendung und einer Reihe von Befehlszeilenargumenten, eines Benutzernamens, eines Kennworts und einer Domäne und ordnet die Ressource einer neuen Process-Komponente zu. | .gif) | ToString | Formatiert den Prozessnamen als Zeichenfolge, ggf. kombiniert mit dem Typ der übergeordneten Komponente. (Überschreibt Component..::.ToString()()().) | .gif) | WaitForExit()()() | Weist die Process-Komponente an, unbestimmte Zeit zu warten, bis der zugeordnete Prozess beendet wird. | .gif) | WaitForExit(Int32) | Weist die Process-Komponente an, für die Dauer von angegebenen Millisekunden zu warten, bis der zugeordnete Prozess beendet wird. | .gif) | WaitForInputIdle()()() | Bewirkt, dass die Process-Komponente unbegrenzt wartet, bis der zugeordnete Prozess in den Leerlauf wechselt. Diese Überladung ist nur für Prozesse mit einer Benutzeroberfläche und einer Nachrichtenschleife gültig. | .gif) | WaitForInputIdle(Int32) | Bewirkt, dass die Process-Komponente die Dauer von angegebenen Millisekunden wartet, bis der zugeordnete Prozess in den Leerlauf wechselt. Diese Überladung ist nur für Prozesse mit einer Benutzeroberfläche und einer Nachrichtenschleife gültig. | Zum Seitenanfang

Ereignisse

Hinweise
Hinweis |
|---|
Ab .NET Framework, Version 2.0, können viele .NET Framework-Methoden und -Eigenschaften nicht mehr auf Leistungsindikatordaten auf anderen Computern verweisen. Diese Änderung wurde vorgenommen, um die Leistung zu verbessern und Benutzern ohne Administratorrechte die Verwendung der Process-Klasse zu ermöglichen. Daher tritt jetzt möglicherweise in einigen Anwendungen, in denen in früheren Versionen von .NET Framework keine Ausnahmen aufgetreten sind, eine NotSupportedException auf. Die Anzahl der betroffenen Methoden und Eigenschaften ist zu groß, um sie hier aufzulisten, doch den Themen zu den betroffenen Membern wurden Informationen über die Ausnahmen hinzugefügt. |
Eine Process-Komponente gewährt den Zugriff auf einen Prozess, der auf einem Computer ausgeführt wird. Ein Prozess ist, vereinfacht ausgedrückt, eine Anwendung während der Ausführung. Ein Thread ist die Basiseinheit, für die das Betriebssystem Prozessorzeit reserviert. Ein Thread kann beliebige Teile des Prozesscodes ausführen. Dies umfasst auch Teile, die derzeit von einem anderen Thread ausgeführt werden. Die Process-Komponente ist ein nützliches Tool für das Starten, Anhalten, Steuern und Überwachen von Anwendungen. Mithilfe der Process-Komponente können Sie eine Liste der Prozesse abrufen, die ausgeführt werden, oder einen neuen Prozess starten. Mit einer Process-Komponente können Sie auf Systemprozesse zugreifen. Nachdem eine Process-Komponente initialisiert wurde, kann sie zum Abrufen von Informationen über den laufenden Prozess verwendet werden. Diese Informationen beinhalten die Gruppe von Threads, die geladenen Module (DLL- und EXE-Dateien) sowie Leistungsinformationen wie die Größe des vom Prozess beanspruchten Speicherplatzes. Wenn Sie im System eine Pfadvariable mit Anführungszeichen deklariert haben, müssen Sie diesen Pfad voll qualifizieren, um einen an dieser Position gefundenen Prozess zu starten. Andernfalls findet das System den Pfad nicht. Wenn z. B. c:\mypath nicht im Pfad enthalten ist und von Ihnen unter Verwendung von Anführungszeichen hinzugefügt wird, wie in path = %path%;"c:\mypath", müssen Sie jeden Prozess in c:\mypath beim Starten voll qualifizieren. Die Prozesskomponente ruft Informationen über eine Gruppe von Eigenschaften gleichzeitig ab. Wenn die Process-Komponente Informationen zu einem Member einer beliebigen Gruppe abgerufen hat, werden die Werte der anderen Eigenschaften in dieser Gruppe zwischengespeichert und keine neuen Informationen zu anderen Membern der Gruppe abgerufen, bis Sie die Refresh-Methode aufrufen. Daher ist ein Eigenschaftswert nicht unbedingt aktueller als der letzte Aufruf der Refresh-Methode. Die Einteilung der Gruppen ist vom Betriebssystem abhängig. Systemprozesse werden im System durch die Prozess-ID eindeutig bezeichnet. Wie viele Windows-Ressourcen kann ein Prozess auch über sein Handle bezeichnet werden, das auf dem Computer nicht unbedingt eindeutig sein muss. Handle ist der Oberbegriff für den Bezeichner einer Ressource. Das Betriebssystem behält das Prozesshandle bei, auf das selbst bei beendetem Prozess über die Handle-Eigenschaft der Process-Komponente zugegriffen werden kann. Auf diese Weise können Sie die administrativen Informationen des Prozesses abrufen, z. B. ExitCode (meist 0 bei Erfolg oder ein Fehlercode ungleich 0) und ExitTime. Handles sind eine besonders nützliche Ressource. Daher sind Handleverluste gravierender als Speicherverluste. Hinweis |
|---|
Diese Klasse enthält eine Link- und eine Vererbungsanforderung auf der Klassenebene, die auf alle Member angewendet wird. Eine SecurityException wird ausgelöst, wenn der direkte Aufrufer oder die abgeleitete Klasse nicht über vollständige vertrauenswürdige Berechtigungen verfügen. Ausführliche Informationen zu Sicherheitsanforderungen finden Sie unter Verknüpfungsaufrufe und Vererbungsforderungen. |

Beispiele
Im folgenden Beispiel wird eine Instanz der Process-Klasse zum Starten eines Prozesses verwendet.
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
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);
}
}
}
}
#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 );
}
}
Im folgenden Beispiel wird die Process-Klasse selbst und eine statische Start-Methode zum Starten eines Prozesses verwendet.
Imports System
Imports System.Diagnostics
Imports System.ComponentModel
Namespace MyProcessSample
Class MyProcess
' Opens the Internet Explorer application.
Public Sub OpenApplication(myFavoritesPath As String)
' Start Internet Explorer. Defaults to the home page.
Process.Start("IExplore.exe")
' Display the contents of the favorites folder in the browser.
Process.Start(myFavoritesPath)
End Sub 'OpenApplication
' Opens urls and .html documents using Internet Explorer.
Sub OpenWithArguments()
' url's are not considered documents. They can only be opened
' by passing them as arguments.
Process.Start("IExplore.exe", "www.northwindtraders.com")
' Start a Web page using a browser associated with .html and .asp files.
Process.Start("IExplore.exe", "C:\myPath\myFile.htm")
Process.Start("IExplore.exe", "C:\myPath\myFile.asp")
End Sub 'OpenWithArguments
' Uses the ProcessStartInfo class to start new processes,
' both in a minimized mode.
Sub OpenWithStartInfo()
Dim startInfo As New ProcessStartInfo("IExplore.exe")
startInfo.WindowStyle = ProcessWindowStyle.Minimized
Process.Start(startInfo)
startInfo.Arguments = "www.northwindtraders.com"
Process.Start(startInfo)
End Sub 'OpenWithStartInfo
Shared Sub Main()
' Get the path that stores favorite links.
Dim myFavoritesPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Favorites)
Dim myProcess As New MyProcess()
myProcess.OpenApplication(myFavoritesPath)
myProcess.OpenWithArguments()
myProcess.OpenWithStartInfo()
End Sub 'Main
End Class 'MyProcess
End Namespace 'MyProcessSample
using System;
using System.Diagnostics;
using System.ComponentModel;
namespace MyProcessSample
{
class MyProcess
{
// Opens the Internet Explorer application.
void OpenApplication(string myFavoritesPath)
{
// Start Internet Explorer. Defaults to the home page.
Process.Start("IExplore.exe");
// Display the contents of the favorites folder in the browser.
Process.Start(myFavoritesPath);
}
// Opens urls and .html documents using Internet Explorer.
void OpenWithArguments()
{
// url's are not considered documents. They can only be opened
// by passing them as arguments.
Process.Start("IExplore.exe", "www.northwindtraders.com");
// Start a Web page using a browser associated with .html and .asp files.
Process.Start("IExplore.exe", "C:\\myPath\\myFile.htm");
Process.Start("IExplore.exe", "C:\\myPath\\myFile.asp");
}
// Uses the ProcessStartInfo class to start new processes,
// both in a minimized mode.
void OpenWithStartInfo()
{
ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
Process.Start(startInfo);
startInfo.Arguments = "www.northwindtraders.com";
Process.Start(startInfo);
}
static void Main()
{
// Get the path that stores favorite links.
string myFavoritesPath =
Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
MyProcess myProcess = new MyProcess();
myProcess.OpenApplication(myFavoritesPath);
myProcess.OpenWithArguments();
myProcess.OpenWithStartInfo();
}
}
}
#using <System.dll>
using namespace System;
using namespace System::Diagnostics;
using namespace System::ComponentModel;
// Opens the Internet Explorer application.
void OpenApplication( String^ myFavoritesPath )
{
// Start Internet Explorer. Defaults to the home page.
Process::Start( "IExplore.exe" );
// Display the contents of the favorites folder in the browser.
Process::Start( myFavoritesPath );
}
// Opens urls and .html documents using Internet Explorer.
void OpenWithArguments()
{
// url's are not considered documents. They can only be opened
// by passing them as arguments.
Process::Start( "IExplore.exe", "www.northwindtraders.com" );
// Start a Web page using a browser associated with .html and .asp files.
Process::Start( "IExplore.exe", "C:\\myPath\\myFile.htm" );
Process::Start( "IExplore.exe", "C:\\myPath\\myFile.asp" );
}
// Uses the ProcessStartInfo class to start new processes,
// both in a minimized mode.
void OpenWithStartInfo()
{
ProcessStartInfo^ startInfo = gcnew ProcessStartInfo( "IExplore.exe" );
startInfo->WindowStyle = ProcessWindowStyle::Minimized;
Process::Start( startInfo );
startInfo->Arguments = "www.northwindtraders.com";
Process::Start( startInfo );
}
int main()
{
// Get the path that stores favorite links.
String^ myFavoritesPath = Environment::GetFolderPath( Environment::SpecialFolder::Favorites );
OpenApplication( myFavoritesPath );
OpenWithArguments();
OpenWithStartInfo();
}

Versionsinformationen
.NET FrameworkUnterstützt in: 4, 3.5, 3.0, 2.0, 1.1, 1.0 .NET Framework Client ProfileUnterstützt in: 4, 3.5 SP1

.NET Framework-Sicherheit
- LinkDemand
für volle Vertrauenswürdigkeit für den unmittelbaren Aufrufer. Diese Klasse kann von teilweise vertrauenswürdigem Code nicht verwendet werden. - InheritanceDemand
für volle Vertrauenswürdigkeit für Erben. Diese Klasse kann nicht von teilweise vertrauenswürdigem Code geerbt werden.

Plattformen
Windows 7, Windows Vista SP1 oder höher, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core wird nicht unterstützt), Windows Server 2008 R2 (Server Core wird mit SP1 oder höher unterstützt), Windows Server 2003 SP2
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen für .NET Framework.

Threadsicherheit
Alle öffentlichen static ( Shared in Visual Basic)-Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Siehe auch
|