The Start-Process cmdlet in PowerShell starts one or more processes on the local computer. The saps and start are the two aliases for this cmdlet.
We can use the following parameters of Start-Process cmdlet to specify the options, such as starting a process in new window, loading a user profile, or using the alternate credentials.
The -FilePath parameter is used to specify the filename of a program which runs in a process. Enter the name of document file or executable file, which is associated with the program on a computer.
The -ArgumentList parameter specifies the parameter and its values to use when the cmdlet begins the process.
The -Credential parameter is used to give permissions to the user account to perform the process.
This parameter is used to specify the location of a file which executes in a process.
This parameter is used in this cmdlet to load the user profile of windows, which is stored in the HKEY_USERS registry key for the current user.
This parameter starts the new process in the console of current window. By default, the PowerShell opens a new window for executing a new process.
This parameter returns the object for each process, which is started by the cmdlet.
This parameter sends the errors which are created by a process to the specified file. When using this cmdlet, you need to enter the path and name of the file. By default, the errors of a process are displayed on the console.
When this parameter is used in the command, the processes can read the inputs from the specified file. To use this parameter, you need to enter the path and name of the file. By default, a process reads the inputs from the keyboard.
This parameter sends the output, which is created by a process to the specified file. When using this cmdlet, you need to enter the path and name of the file. By default, the output of a process is displayed on the console.
This parameter is used to specify the windows state, which is used for the new process. Following are the acceptable values for this parameter:
- Normal (Default value)
- Maximized, and
Note: We cannot use both the parameters NoNewWindow and WindowStyle in the same command.
This parameter is used in this cmdlet to wait for a process to be completed before accepting any more inputs.
Example 1: open a file of notepad using a variable
In this example, the first command uses a variable which stores the text file. The second command opens a text file by using the variable with Start-Process cmdlet.
Example 2: Start PowerShell as an administrator
In this example, the command starts the PowerShell by using the “Run as Administrator” option.
Example 3: Start a process in a maximized window
In this example, the command starts the notepad.exe process. The command maximizes the notepad window and retains the window until the process completes.