TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

PowerShell Start-Process

PowerShell Start-Process with What is PowerShell, History of PowerShell, Features of PowerShell, PowerShell vs CMD, PowerShell Scripting, PowerShell Versions, PowerShell Commands, PowerShell Looping, PowerShell Conditions, PowerShell Array, PowerShell Brackets etc.

<< Back to POWERSHELL

PowerShell Start-Process

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.

Syntax

Start-Process 
[-FilePath] <string> 
[[-ArgumentList] <string[]>] 
[-Credential <pscredential>] 
[-WorkingDirectory <string>] 
[-LoadUserProfile] 
[-NoNewWindow] 
[-PassThru] 
[-RedirectStandardError <string>] 
[-RedirectStandardInput <string>] 
[-RedirectStandardOutput <string>] 
[-WindowStyle {Normal | Hidden | Minimized | Maximized}] 
[-Wait]
[-UseNewEnvironment]  
[<CommonParameters>]

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

Parameters

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.

-FilePath

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.

-ArgumentList

The -ArgumentList parameter specifies the parameter and its values to use when the cmdlet begins the process.

-Credential

The -Credential parameter is used to give permissions to the user account to perform the process.

-WorkingDirectory

This parameter is used to specify the location of a file which executes in a process.

-LoadUserProfile

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.

-NoNewWindow

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.

-PassThru

This parameter returns the object for each process, which is started by the cmdlet.

-RedirectStandardError

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.

-RedirectStandardInput

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.

-RedirectStandardOutput

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.

-WindowStyle

This parameter is used to specify the windows state, which is used for the new process. Following are the acceptable values for this parameter:

  • Hidden
  • Normal (Default value)
  • Maximized, and
  • Minimized

Note: We cannot use both the parameters NoNewWindow and WindowStyle in the same command.

-Wait

This parameter is used in this cmdlet to wait for a process to be completed before accepting any more inputs.

Examples

Example 1: open a file of notepad using a variable

PowerShell Start-Process

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

PowerShell Start-Process

In this example, the command starts the PowerShell by using the "Run as Administrator" option.

Example 3: Start a process in a maximized window

PowerShell Start-Process

In this example, the command starts the notepad.exe process. The command maximizes the notepad window and retains the window until the process completes.






Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf