Compartir a través de


How to: Specify Processes 

You can use the Process component to start processes on your system by calling the Start method. Before you call Start, you must specify the file name of the process to start by setting the FileName property to either the fully qualified path to the target process, or in the case of qualified Windows applications such as Notepad, simply the process name.

You can set the FileName property at design time, using the Properties window, or at run time by using a value of the StartInfo property. If you set the file name at run time, you can do one of the following:

  • Set the appropriate value of the StartInfo property and then call Start, or

  • Call the Shared form of the Start method and specify file name as a parameter. Use this approach if you do not need to set any other starting parameters; you cannot set any other opening arguments in this method.

To start a process at run time using the StartInfo properties

  1. Set the starting information by exposed by the StartInfo property.

  2. Call the Start method of the Process component.

    The following example shows how to open Notepad in a maximized window.

    Dim myProcess As New Process()
    myProcess.StartInfo.FileName = "Notepad.exe"
    myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized
    myProcess.Start()
    
    Process myProcess = new Process();
    myProcess.StartInfo.FileName = "Notepad";
    myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
    myProcess.Start();
    

To start a process at run time by passing the FileName parameter

  • Call the Start method, entering the file name parameter as a string expression.

    Dim myProcess As Process = Process.Start("Notepad.exe")
    
    Process myProcess = Process.Start("Notepad");
    

See Also

Tasks

How to: Create Process Components

Concepts

Introduction to Monitoring and Managing Windows Processes

Other Resources

Managing Processes