Export (0) Print
Expand All
Collapse the table of content
Expand the table of content
Expand Minimize

Start-Process

Updated: August 9, 2015

Start-Process

Starts one or more processes on the local computer.

Aliases

The following abbreviations are aliases for this cmdlet: 

  • saps, start

Syntax

Parameter Set: Default
Start-Process [-FilePath] <String> [[-ArgumentList] <String[]> ] [-Credential <PSCredential> ] [-LoadUserProfile] [-NoNewWindow] [-PassThru] [-RedirectStandardError <String> ] [-RedirectStandardInput <String> ] [-RedirectStandardOutput <String> ] [-UseNewEnvironment] [-Wait] [-WindowStyle <ProcessWindowStyle> {Normal | Hidden | Minimized | Maximized} ] [-WorkingDirectory <String> ] [ <CommonParameters>]

Parameter Set: UseShellExecute
Start-Process [-FilePath] <String> [[-ArgumentList] <String[]> ] [-PassThru] [-Verb <String> ] [-Wait] [-WindowStyle <ProcessWindowStyle> {Normal | Hidden | Minimized | Maximized} ] [-WorkingDirectory <String> ] [ <CommonParameters>]




Detailed Description

The Start-Process cmdlet 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, similar to 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 this cmdlet starts the process.


Aliases

Args

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.


Aliases

RunAs

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-FilePath<String>

Specifies the optional path 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.


Aliases

PSPath

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-LoadUserProfile

Indicates that this cmdlet loads the Windows user profile stored in the HKEY_USERS registry key for the current user.

This parameter does not affect the Windows PowerShell profiles. For more information, see about_Profiles.


Aliases

Lup

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-NoNewWindow

Start the new process in the current console window. By default Windows PowerShell opens a new window.

You cannot use the NoNewWindow and WindowStyle parameters in the same command.


Aliases

nnw

Required?

false

Position?

named

Default Value

none

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.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-RedirectStandardError<String>

Specifies a file. This cmdlet 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.


Aliases

RSE

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-RedirectStandardInput<String>

Specifies a file. This cmdlet 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.


Aliases

RSI

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-RedirectStandardOutput<String>

Specifies a file. This cmdlet 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.


Aliases

RSO

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-UseNewEnvironment

Indicates that this cmdlet uses new environment variables specified for the process. By default, the started process runs with the environment variables specified for the computer and user.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Verb<String>

Specifies a verb to use when this cmdlet starts 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.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Wait

Indicates that this cmdlet waits for the specified process to complete before accepting more input. This parameter suppresses the command prompt or retains the window until the process finishes.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WindowStyle<ProcessWindowStyle>

Specifies the state of the window that is used for the new process. The acceptable values for this parameter are: Normal, Hidden, Minimized, and Maximized. The default value is Normal.

You cannot use the WindowStyle and NoNewWindow parameters in the same command.


Aliases

none

Required?

false

Position?

named

Default Value

none

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 folder.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see    about_CommonParameters.

Inputs

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

  • None

    You cannot pipe input to this cmdlet.


Outputs

The output type is the type of the objects that the cmdlet emits.

  • None, System.Diagnostics.Process

    This cmdlet generates a System.Diagnostics.Process object, if you specify the PassThru parameter. 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 (http://go.microsoft.com/fwlink/?LinkId=143602) in the Microsoft Developer Network (MSDN) library.

Examples

Example 1: Start a process that uses default values

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


PS C:\> Start-Process -FilePath "sort.exe"

Example 2: Print a text file

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


PS C:\> Start-Process -FilePath "myfile.txt" -WorkingDirectory "C:\PS-Test" -Verb Print

Example 3: Start a process to sort items to a new file

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.


PS C:\> Start-Process -FilePath "Sort.exe" -RedirectStandardInput "Testsort.txt" -RedirectStandardOutput "Sorted.txt" -RedirectStandardError "SortError.txt" -UseNewEnvironment

Example 4: Start a process in a maximized window

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


PS C:\> Start-Process -FilePath "notepad" -Wait -WindowStyle Maximized

Example 5: Start Windows Powershell as an administrator

This command starts Windows PowerShell by using the Run as administrator option.


PS C:\> Start-Process -FilePath "powershell" -Verb runAs

Example 6: Using different verbs to start a process

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. This example uses the PowerShell.exe file that runs in the PowerShell process.

The first command uses New-Object 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 by using the Run as administrator option.


PS C:\> $startExe = New-Object System.Diagnostics.ProcessStartInfo -Args PowerShell.exe
PS C:\> $startExe.verbs
open
runas

# Starts a PowerShell process in a new console window.

PS C:\> Start-Process -FilePath "powershell.exe" -Verb open

# Starts a PowerShell process with "Run as Administrator" permissions.

PS C:\> Start-Process -FilePath "powershell.exe" -Verb runas

Related topics

Community Additions

ADD
Show:
© 2016 Microsoft