Name
Process
Synopsis
This class represents a system process. Use it to start, stop, and
interact with a process.
To launch a new process, create an instance of
ProcessStartInfo
, set its properties, and pass
it to the single-argument form of the static
Start()
method. This offers a great deal of
control over process creation. To launch a process without
customizing its StartInfo
, simply call the one-string
or two-string argument form of the static Start()
method.
The first string argument is the name of the program, batch file,
or document to start, and the optional second argument
contains any command-line arguments.
You can also explicitly create a new instance of
Process
, set its StartInfo
property, and call the Start()
method to start
the process.
GetCurrentProcess()
creates a
Process
instance that represents the current
process.
Enumerate all running processes on the system by using
GetProcesses()
.
Use GetProcessesByName()
to get all processes
for a given program.
GetProcessById()
retrieves a
Process
given its process ID.
Use
CloseMainWindow()
to shut down a process that has
a user interface. You can terminate a process with
Kill()
, but this forces an abnormal termination,
which may result in data corruption. If you would like to raise an
event when the process finishes executing, use
Exited
(EnableRaisingEvents
must be set to true
).
Most of the properties allow you to access general information about the running process. However, this information is populated at the time ...
Get C# in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.