. Advertisement .
..3..
. Advertisement .
..4..
The tutorial belows will walk you through the spectrum of Powershell Start Process as well as how to make the best out of it. Jump right in for further details!
What Is The PowerShell Start Process?
PowerShell is a scripting language for managing and automating Windows and Windows Server systems. It may be run from a text-based shell or from scripts that have been stored.
As such, the Start-Process cmdlet in PowerShell is a tool for you to start an executable file, a script file, for example.
If that file is non-executable, it will launch the application associated with it.
That way, Start-Process has arguments that allow you to specify options like starting the process in a new window, loading a user profile, and utilizing other credentials.
Start-Process Parameters
It can be said that the cmdlet’s power is even increased by accompanying parameters. For instance, this will open Notepad, maximize the window, and keep it unclosed until the user get the task done with it:
PS C:\> Start-Process -FilePath “notepad” -Wait -WindowStyle Maximized
The list of parameters being of use consists of:
- -Credential: Enter the username and password for the user account that will be used to complete the operation. The current user is the default credential.
- -ArgumentList: The list of parameters or parameter values that will be used.
- -LoadUserProfile: Determine the program or document to be executed file path and name.
- -FilePath (required): Specify the file path and file name of the program or document to be executed.
- -PassThru: Run the process in the current console window instead of a new one, which is the default.
- -NoNewWindow: Load the current user’s Windows user profile.
- -RedirectStandardInput: Read data from a file with the path and name supplied.
- -RedirectStandardError: Instead of showing errors on the console, send error messages to a file provided by path and file name.
- -RedirectStandardOutput: Send output to a file with the location and name supplied.
- -Verb: Execute an action that is compatible with the file name extension of the provided file.
- -UseNewEnvironment: Employ new environment variables for the machine and user instead of the default environment variables.
- -WindowStyle: Set the window’s state for the new process. Optional features include Normal\ Minimized\ Hidden\Maximized.
- -Wait: Prior to actually taking any further inputs, wait for the procedure to complete.
- CommonParameters: This is the one that any cmdlet can utilize.
- -WorkingDirectory: Provide the path of the file that will be run. The current directory is the default.
Syntax To Implement The PowerShell Start Process
[-FilePath] <String>
[[-ArgumentList] <String[]>]
[-Credential <PSCredential>]
[-WorkingDirectory <String>]
[-LoadUserProfile]
[-NoNewWindow]
[-PassThru]
[-RedirectStandardError <String>]
[-RedirectStandardInput <String>]
[-RedirectStandardOutput <String>]
[-WindowStyle <ProcessWindowStyle>]
[-Wait]
[-UseNewEnvironment]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Some Examples Of The Cmdlets
Printing a File
PS C:\> start-process PrintThisFile.txt -verb Print
Getting the Process ID
$process = Start-Process "C:\temp\example.bat" -PassThru
$process.ID
Create A Detached Process On Linux
Start-Process nohup 'pwsh -noprofile -c "1..120 | % { Write-Host . -NoNewline; sleep 1 }"'
Maximum Width Window
PS C:\> $Path = "C:\Program Files\Internet Explorer"
PS C:\> Start-Process -WorkingDirectory $Path iexplore.exe -WindowStyle Maximized
Wrapping It up
Above is neatly all that you need to grasp about the PowerShell Start Process. Hopefully, our tutorial can be of great benefit to you. And don’t forget to leave a comment if you have anything confusing regarding such a language’s operation such as calling a method on a null-value expression or so. See then!
Leave a comment