Questions tagged [start-process]

Start-Process is a PowerShell cmdlet that starts one or more processes on the local computer.

Start-Process is a PowerShell cmdlet that 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.

Output

  • 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.
204 questions
128
votes
9 answers

Capturing standard out and error with Start-Process

Is there a bug in PowerShell's Start-Process command when accessing the StandardError and StandardOutput properties? If I run the following I get no output: $process = Start-Process -FilePath ping -ArgumentList localhost -NoNewWindow -PassThru…
jzbruno
  • 1,378
  • 2
  • 10
  • 7
81
votes
5 answers

PowerShell - Start-Process and Cmdline Switches

I can run this fine: $msbuild = "C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe" start-process $msbuild -wait But when I run this code (below) I get an error: $msbuild = "C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe /v:q /nologo"…
BuddyJoe
  • 64,613
  • 107
  • 281
  • 451
15
votes
7 answers

Start-process raises an error when providing Credentials - possible bug

Would you possibly know why this error is being raised in response to the code below. User-name and password have been verified as correct. $secPassword = ConvertTo-SecureString "Password" -AsPlaintext -Force $farmCredential = New-Object…
chris
  • 183
  • 2
  • 2
  • 6
15
votes
4 answers

How to run a process as non-admin from an elevated PowerShell console?

Maybe there is a way to do it with Start-Process cmdlet that I cannot find? The other related Q/A's I found on StackOverflow such as this, this and this all give a solution to do this with a custom C# code. My question is specifically, is there any…
orad
  • 12,746
  • 18
  • 69
  • 107
14
votes
1 answer

Powershell Start Process, Wait with Timeout, Kill and Get Exit Code

I want to repeatedly execute a program in a loop. Sometimes, the program crashes, so I want to kill it so the next iteration can correctly start. I determine this via timeout. I have the timeout working but cannot get the Exit Code of the program,…
Andreas Reiff
  • 6,615
  • 9
  • 43
  • 94
13
votes
3 answers

running dos command line from C#?

I am trying to run this command from command-line prompt: "D:\\fiji\\fiji.exe -macro D:\\fiji\\macros\\FFTBatch.ijm --headless" It works perfect when I type it in a command-line console. However, when I was trying to make it work from C#…
Nick X Tsui
  • 2,400
  • 6
  • 31
  • 62
11
votes
4 answers

How to start a console-based process and apply a custom title using Powershell

I am converting an old cmd command to Powershell, and currently use: START "My Title" Path/To/ConsoleApp.exe This works as expected to launch ConsoleApp with My Title as it's window title. This has been replaced with Start-Process which works…
Ben Laan
  • 2,577
  • 3
  • 29
  • 30
11
votes
3 answers

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment

I'm running into a strange behavior with a powershell Start-Process call. Here is the call: $process = start-process ` "C:\somepath\MyBinary.exe" ` -PassThru ` -Credential $defaultCredential ` -Wait ` -WorkingDirectory …
John-Philip
  • 2,838
  • 2
  • 20
  • 48
10
votes
4 answers

Starting .ps1 Script from PowerShell with Parameters and Credentials and getting output using variable

Hello Stack Community :) I have a simple goal. I'd like to start some PowerShell Script from an another Powershell Script, but there are 3 conditions: I have to pass credentials (the execution connects to a database that has specific user) It has…
Dmytro
  • 312
  • 2
  • 11
10
votes
5 answers

Powershell opening file path with whitespaces

I'm my PS script I want to be able to run another script in another PS instance by doing the following: $filepath = Resolve-Path "destruct.ps1" start-process powershell.exe "$filepath" destruct.ps1 is in the same folder as this script. However…
user3402227
  • 237
  • 2
  • 4
  • 10
9
votes
1 answer

Start-Process -wait doesn't work when script is launched from command prompt opened with runas or as a scheduled task

I've got a script that's I want to run as a scheduled task, but it's not doing the thing it's supposed to. I'm trying to call an executable with Start-Process and the -Wait switch before continuing. Line is Start-Process -FilePath "C:\Pfx…
8
votes
1 answer

Start non-elevated process from elevated process

Possible Duplicate: How to run NOT elevated in Vista (.NET) How do you de-elevate privileges for a child process My program running as an elevated process, and starting new processes with Process.Start(). For security reasons, I would like to run…
DxCK
  • 4,052
  • 6
  • 44
  • 86
8
votes
8 answers

Launch Metro style apps using powershell

I am trying to write a powershell script for windows 10 that will automatically launch a Metro-style app. The Start-Process cmdlet seems like it should work, but I cannot get it to launch anything unless I provide a path to the .exe For example, the…
Flopdong
  • 239
  • 1
  • 2
  • 12
8
votes
1 answer

"Start-Process -NoNewWindow" within a Start-Job?

I'm having issues using Start-Process within a Start-Job, specifically when using -NoNewWindow. For example, this test code: Start-Job -scriptblock { Start-Process cmd -NoNewWindow -Wait -ArgumentList '/c', 'echo' | out-null Start-Process…
Joe
  • 3,667
  • 1
  • 23
  • 35
7
votes
1 answer

PowerShell 1.0 Start-Process not waiting for complete when user logged off

I'm currently trying to use Powershell to connect to a remote desktop, run a program on that desktop, and then log off. I am then checking the output of running that command across a fileshare. Basically this means that PowerShell should wait for…
panditbandit
  • 73
  • 1
  • 8
1
2 3
13 14