Starts one or more processes on the local computer.

Syntax

  Copy Code
Start-Process [-FilePath] <string> [[-ArgumentList] <string[]>] [-Credential <PSCredential>] [-LoadUserProfile] [-NoNewWindow] [-PassThru] [-RedirectStandardError <string>] [-RedirectStandardInput <string>] [-RedirectStandardOutput <string>] [-UseNewEnvironment] [-Wait] [-WorkingDirectory <string>] [<CommonParameters>]

Start-Process [-FilePath] <string> [[-ArgumentList] <string[]>] [-PassThru] [-Verb <string>] [-Wait] [-WindowStyle {<Normal> | <Hidden> | <Minimized> | <Maximized>}] [-WorkingDirectory <string>] [<CommonParameters>]

Description

Starts one or more processes on the local computer. To specify the program that runs in the process, enter an executable file or script file, or a file that can be opened by using a program on the computer. If you specify a non-executable file, Start-Process starts the program that is associated with the file, much like the Invoke-Item cmdlet.

You can use the parameters of Start-Process to specify options, such as loading a user profile, starting the process in a new window, or using alternate credentials.

Parameters

-ArgumentList <string[]>

Specifies parameters or parameter values to use when starting the process. The parameter name ("Arguments") is optional.

Required?

false

Position?

2

Default Value

None

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Credential <PSCredential>

Specifies a user account that has permission to perform this action. Type a user-name, such as "User01" or "Domain01\User01", or enter a PSCredential object, such as one from the Get-Credential cmdlet. By default, the cmdlet uses the credentials of the current user.

Required?

false

Position?

named

Default Value

Current user.

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-FilePath <string>

Specifies the path (optional) and file name of the program that runs in the process. Enter the name of an executable file or of a document, such as a .txt or .doc file, that is associated with a program on the computer. This parameter is required.

If you specify only a file name, use the WorkingDirectory parameter to specify the path.

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-LoadUserProfile

Loads the Windows user profile stored in the HKEY_USERS registry key for the current user. The default value is FALSE.

This parameter does not affect the Windows PowerShell profiles. (See about_Profiles.)

Required?

false

Position?

named

Default Value

False

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-NoNewWindow

Prevents the process from running in a new window. By default, the process runs in a new window.

Required?

false

Position?

named

Default Value

False

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PassThru

Returns a process object for each process that the cmdlet started. By default, this cmdlet does not generate any output.

Required?

false

Position?

named

Default Value

False

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-RedirectStandardError <string>

Sends any errors generated by the process to a file that you specify. Enter the path and file name. By default, the errors are displayed in the console.

Required?

false

Position?

named

Default Value

Errors are displayed in the console

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-RedirectStandardInput <string>

Reads input from the specified file. Enter the path and file name of the input file. By default, the process gets its input from the keyboard.

Required?

false

Position?

named

Default Value

Keyboard

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-RedirectStandardOutput <string>

Sends the output generated by the process to a file that you specify. Enter the path and file name. By default, the output is displayed in the console.

Required?

false

Position?

named

Default Value

FALSE

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-UseNewEnvironment

Use new environment variables specified for the process. By default, the started process runs with the environment variables specified for the computer and user.

Required?

false

Position?

named

Default Value

False

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Verb <string>

Specifies a verb to use when starting the process. The verbs that are available are determined by the file name extension of the file that runs in the process.

The following table shows the verbs for some common process file types.

File type Verbs

--------- -------

.cmd Edit, Open, Print, Runas

.exe Open, RunAs

.txt Open, Print, PrintTo

.wav Open, Play

To find the verbs that can be used with the file that runs in a process, use the New-Object cmdlet to create a System.Diagnostics.ProcessStartInfo object for the file. The available verbs are in the Verbs property of the ProcessStartInfo object. For details, see the examples.

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Wait

Waits for the specified process to complete before accepting more input. This parameter suppresses the command prompt or retains the window until the process completes.

Required?

false

Position?

named

Default Value

False

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WindowStyle <ProcessWindowStyle>

Specifies the state of the windows used for the process. Valid values are Normal, Hidden, Minimized, and Maximized. The default value is Normal.

Required?

false

Position?

named

Default Value

Normal

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WorkingDirectory <string>

Specifies the location of the executable file or document that runs in the process. The default is the current directory.

Required?

false

Position?

named

Default Value

Current directory

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This command supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, OutBuffer, OutVariable, WarningAction, and WarningVariable. For more information, see about_CommonParameters.

Inputs and Outputs

The input type is the type of the objects that you can pipe to the cmdlet. The return type is the type of the objects that the cmdlet returns.

Inputs

None

You cannot pipe input to Start-Process.

Outputs

None or System.Diagnostics.Process

When you use the PassThru parameter, Start-Process generates a System.Diagnostics.Process. Otherwise, this cmdlet does not return any output.

Notes

This cmdlet is implemented by using the Start method of the System.Diagnostics,Process class. For more information about this method, see "Process.Start Method" in the MSDN (Microsoft Developer Network) library at http://go.microsoft.com/fwlink/?LinkId=143602.

Example 1

  Copy Code
C:\PS>start-process sort.exe

Description
-----------
This command starts a process that uses the Sort.exe file in the current directory. The command uses all of the default values, including the default window style, working directory, and credentials.






Example 2

  Copy Code
C:\PS>start-process myfile.txt -workingdirectory "C:\PS-Test" -verb Print

Description
-----------
This command starts a process that prints the C:\PS-Test\MyFile.txt file.






Example 3

  Copy Code
C:\PS>start-process Sort.exe -RedirectStandardInput Testsort.txt -RedirectStandardOutput Sorted.txt -RedirectStandardError SortError.txt -UseNewEnvironment

Description
-----------
This command starts a process that sorts items in the Testsort.txt file and returns the sorted items in the Sorted.txt files. Any errors are written to the SortError.txt file. 

The UseNewEnvironment parameter specifies that the process runs with its own environment variables.






Example 4

  Copy Code
C:\PS>start-process notepad -wait -windowstyle Maximized

Description
-----------
This command starts the Notepad process. It maximizes the window and retains the window until the process completes.






Example 5

  Copy Code
C:\PS>start-process powershell -verb runAs

Description
-----------
This command starts Windows PowerShell with the "Run as administrator" option.






Example 6

  Copy Code
C:\PS>$startExe = new-object System.Diagnostics.ProcessStartInfo -args PowerShell.exe

C:\PS> $startExe.verbs
open
runas

# Starts a PowerShell process in a new console window.
C:\PS> start-process powershell.exe -verb open

# Starts a PowerShell process with "Run as Administrator" permissions.
C:\PS> start-process powershell.exe -verb runas

Description
-----------
These commands show how to find the verbs that can be used when starting a process, and the effect of using the verbs to start the process.

The available verbs are determined by the file name extension of the file that runs in the process. To find the verbs for a process, create a System.Diagnostics.ProcessStartInfo object for the process file and look in the Verbs property of the object. In this example, we'll use the PowerShell.exe file that runs in the PowerShell process.

The first command uses the New-Object cmdlet to create a System.Diagnostics.ProcessStartInfo object for PowerShell.exe, the file that runs in the PowerShell process. The command saves the ProcessStartInfo object in the $startExe variable.

The second command displays the values in the Verbs property of the ProcessStartInfo object in the $startExe variable. The results show that you can use the Open and Runas verbs with PowerShell.exe, or with any process that runs a .exe file.

The third command starts a PowerShell process with the Open verb. The Open verb starts the process in a new console window.

The fourth command starts a PowerShell process with the RunAs verb. The RunAs verb starts the process with permissions of a member of the Administrators group on the computer. This is the same as starting Windows PowerShell with the "Run as administrator" option.






See Also