EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials PowerShell Tutorial PowerShell Start-Process
 

PowerShell Start-Process

Priya Pedamkar
Article byPriya Pedamkar

PowerShell Start-Process

Introduction to PowerShell Start-Process

Many times when we are working with process and file system then we need some way by which we could be able to handle files opening and writing and executing to any .exe file from command. Start-Process command allows us to open process at by command line. It has the power to capture error or output of the command in any mentioned file or read inputs from any mentioned file. Other than simply opening any process it allows many more functionalities like, We can use Start-Process to define some alternative ways to

 

 

  • Getting or loading user(it will take current user profile details if nothing passed) profile details,
  • Allow to start a new process in various formats(normal, minimized, maximized, etc) in the new Window. In Simple manner, it defines state for the window for a new process
  • An alternative option for credentials. If we do not mention credential section then it will read current user credentials

Syntax and Parameters

Syntax of PowerShell Start-Process are given below:

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Syntax #1:

Start-Process
[-FilePath] <String>
[[-ArgumentList] <defines string parameters value>] [-Credential <related to permission for the user to run the command, it can be PSCredential
also>] [-WorkingDirectory <string value of working directories >] [-LoadUserProfile<Here it will load user profile>] [-NoNewWindow] [-PassThru<Holds the details of process like process id etc>] [-RedirectStandardError <string path  of file where error will be written>] [-RedirectStandardInput <string path of file from where input will be read>] [-RedirectStandardOutput <string path of file to where output will be written>] [-WindowStyle <Allow us to open in various formats like normal ,maximized and minimized>] [-Wait<wait for previous input processing>] [-UseNewEnvironment] [-WhatIf<display what happen on execution of command>] [-Confirm<display a confirmation before execution of command>] [<CommonParameters>]

Syntax #2:

Start-Process
[-FilePath] <String>
[[-ArgumentList] <defines parameters value>] [-WorkingDirectory <String>] [-PassThru] [-Verb <String>] [-WindowStyle <ProcessWindowStyle>] [-Wait<wait for previous input processing>] [-WhatIf<display what happen on execution of command>] [-Confirm<display a confirmation before execution of command>] [<CommonParameters>]

Parameters

Parameters of PowerShell Start-Process.

  • ArgumentList: It defines parameter values that will be used when the command will start. We can use space also between parameters, the only thing we need to take care of when space is taken in that case we should put parameters in escaped double quotes.
  • Confirm: Its name is clearly specifying its meaning. It will prompt confirmation before you run the command for ensuring from your side.
  • Credential: It’s used for security purposes, It defines a user with permission to run the command. If we do not pass parameters for this command it will take credentials of the current users.
  • FilePath: Defines the alternative path and filename for the program which will run in the process. Here we need to pass the directory along with the file name(file for processing), if we do not provide path or directory it will use the current working directory with the same file name.
  • LoadUserProfile: It will load the profile of the current Windows user which is stored in the HKEY_USERS registry.
  • NoNewWindow: It allows us to run a new process in the current Windows console. Remember PowerShell will always open a new window if we do not provide value to this parameter.
  • RedirectStandardError: It defines a file. With the help of this command, we can send errors generated by our command to a file Here we need to mention the file name for capturing this error. So if we do not mention the file then it will send error on the console.
  • RedirectStandardInput: Suppose you want our process to read inputs from any file then we can use this parameter. In this parameter, we have to mention the path of the file from where our command will read inputs. If we do not mention file name then the process will read inputs from entering values from the keyboard.
  • RedirectStandardOutput: Again, here if we want to capture output generated by the process to any file then we can define file name and path, and the output of the process will be posted on the mentioned file. In case if we do not mention file name than output will be displayed on the console screen.
  • UseNewEnvironment: This command takes any new environment variables that defines the process. In case if we do not pass any argument to this command it will take environment variables of current computer and user.
  • Wait: Suppose you have passed many inputs to process in command, in that case, we use this attribute(Wait) as it will allow the process to wait to complete processing of previous input.
  • WhatIf: It will display consequences after executing the command. This command will support only after PowerShell version 6 or later.
  •  WindowStyle: It will allow us to open a new process in various formats according to our convenience on the computer. It has several formats like Normal, Hidden, Minimize, and maximized. We need this command because it gives us various ways to open the process and see them.

Examples to Implement PowerShell Start-Process

Following are the powershell start-process are:

Example #1

In the below example we are inside the ranjan1 folder and we want to open a file with name test2.txt in any default editor. It started the process by opening the file. It is a simple example where we are just opening a given file, please see the example along with the screen.

Start-Process test2.txt

Output:

It will open the text file specified.

Example #2

This is the based example where we can see the creation of any process and stopping of that process with process id. Here we are capturing process details with the help of command called -Passthru which generally gets current process details with object formats. In this example variable $procDetails contains details of the process which started. We can get the process id from this variable by writing $procDetails.id and with the id we can perform any operation on the current running process. For example below we are stopping the process with the unique process id. And the qwfile will be closed .

$procDetails = Start-Process test2.txt -Passthru
$procDetails.id

Output:

PowerShell Start-Process-1.1

Stop-Process -id 9820

Output:

It will close the text file according to id which is specified above.

Example #3

In this example we are using –Confirm, we can see on the execution of below command first it is asking for yes(Y) or not (N), so if we enter Y than it will open the file, and if we Enter N it would not open the file. Please follow the below command along with the screen.

Start-Process -FilePath "test2.txt" --Confirm

PowerShell Start-Process-1.2

Recommended Articles

This is a guide to PowerShell Start-Process. Here we also discuss the introduction and syntax of powershell start-process along with different examples and its code implementation. You may also have a look at the following articles to learn more –

  1. PowerShell Continue
  2. PowerShell Send Mail
  3. PowerShell vs PowerShell ISE
  4. PowerShell Functions

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW