Questions tagged [start-process]

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

start-process
Filter by
Sorted by
Tagged with
168 votes
12 answers
307k views

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 -...
jzbruno's user avatar
  • 1,788
85 votes
6 answers
295k views

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....
BuddyJoe's user avatar
  • 70.5k
4 votes
4 answers
14k views

Is there a way to pass serializable objects to a PowerShell script with start-process?

I know about PowerShell jobs, but I want to use start-process and pass a serializable object to the new powershell process. Is there any way to do this? It seems that using start-process you have to ...
Kirk Liemohn's user avatar
  • 7,833
6 votes
4 answers
34k views

Powershell Using Start-Process in PSSession to Open Notepad

I've created a pssession on a remote computer and entered that possession. From within that session I use start-process to start notepad. I can confirm that notepad is running with the get-process ...
Colyn1337's user avatar
  • 1,665
21 votes
7 answers
60k views

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" -...
chris's user avatar
  • 243
22 votes
1 answer
49k views

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 ...
Andreas Reiff's user avatar
9 votes
10 answers
15k views

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 ...
Flopdong's user avatar
  • 369
11 votes
4 answers
11k views

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 ...
Dmytro's user avatar
  • 392
10 votes
0 answers
7k views

Start non-elevated process from elevated process [duplicate]

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 ...
DxCK's user avatar
  • 4,502
2 votes
2 answers
1k views

How to pass a variable to new console window in Powershell

I want to pass a variable to a new console, but I don't know how. $server = "server_name" Start-Process Powershell { $host.ui.RawUI.WindowTitle = “Get-Process” Invoke-Command -...
elpe's user avatar
  • 33
18 votes
5 answers
15k views

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# ...
orad's user avatar
  • 15.7k
12 votes
3 answers
34k views

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, ...
Nick X Tsui's user avatar
  • 2,786
7 votes
5 answers
19k views

Powershell Start-Process to start Powershell session and pass local variables

Is there a way to use the Powershell Start-Process cmdlet to start a new Powershell session and pass a scriptblock with local variables (once of which will be an array)? Example: $Array = @(1,2,3,4) ...
atownson's user avatar
  • 368
6 votes
1 answer
37k views

Powershell Start-Process : This command cannot be executed due to the error: Access is denied

I'm trying to run start-process from a powershell script with given credential. Nevertheless the command fail with the following error: Start-Process : This command cannot be executed due to the ...
John-Philip's user avatar
  • 3,442
13 votes
3 answers
8k views

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 $...
John-Philip's user avatar
  • 3,442
13 votes
1 answer
23k views

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. ...
user3137716's user avatar
7 votes
3 answers
31k views

How to start remotely process in PowerShell

I have a problem, I have a script which: Connect with PSSession (I use PSSession with admin account) Stop 2 process Do change on them files Start the 2 process (Problem here) I want to start process ...
Servuc's user avatar
  • 338
6 votes
1 answer
7k views

redirect stdout, stderr from powershell script as admin through start-process

Inside a powershell script, I'm running a command which starts a new powershell as admin (if I'm not and if needed, depending on $arg) and then runs the script. I'm trying to redirect stdout and ...
Soleil's user avatar
  • 6,792
2 votes
1 answer
2k views

With PowerShell, how to switch minimized application to normal state?

Given a single-instance desktop application ccTest.exe, how can I use PowerShell (v6 or 7) to run the application in the Normal state if it is already running in Minimized state. I need access to ...
cefeg's user avatar
  • 33
1 vote
2 answers
332 views

PowerShell removes multiple consecutive whitespaces when I pass arguments to a nested Start-Process command

This powershell code works fine: powershell -NoProfile -Command {Start-Process -FilePath wscript.exe -Verb RunAs -ArgumentList '"C:\Users\TestAccount\Desktop\cartella con spazi\test.vbs" &...
Mario Palumbo's user avatar
13 votes
8 answers
45k views

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 "$...
user3402227's user avatar
4 votes
2 answers
9k views

Issues with running a PsExec process from code

I am experiencing a weird issue when attempting to run a .NET command line tool remotely using PsExec. When running PsExec from command line, it runs and completes fine. When running it from a ...
lysergic-acid's user avatar
4 votes
5 answers
4k views

Process.Start filename using %temp%

For some odd reaseon this code fails: p.StartInfo.FileName = @"%temp%\SSCERuntime_x86-ENU.msi"; and this code succes: p.StartInfo.FileName = @"C:\Users\USERNAME\AppData\Local\Temp\SSCERuntime_x86-...
Diego's user avatar
  • 16.5k
3 votes
2 answers
9k views

How to handle file paths with special characters?

I've got a PowerShell script that needs to be able to call another PS script from within the same directory with elevated credentials. Because the scripts need to be portable, the file path of the ...
cypher's user avatar
  • 31
2 votes
1 answer
16k views

PowerShell - script 1 calls script 2 - how to return value from script 2 to script 1

I have two PowerShell scripts. One script invokes another PowerShell script using elevated credentials, using Start-Process. But I am struggling with how to make the second script return the output ...
Glowie's user avatar
  • 2,311
2 votes
1 answer
3k views

Why can't I use Start-Process to invoke a script with parameters?

I am trying to write a wrapper script in Powershell which is passed the name of an executable, does some preprocessing, then invokes that executable with arguments resulting from that preprocessing. ...
Chris Nelson's user avatar
  • 3,587
2 votes
2 answers
729 views

Question about using PowerShell Select-String, exiftool(-k)

In a PowerShell script I'm trying to filter the output of the exiftool(-k).exe command below, using Select-String. I've tried numerous permutations, but none work, and I always see the unfiltered ...
zBernie's user avatar
  • 97
2 votes
1 answer
895 views

Can't hit breakpoint in program.main Blazor Client wasm

Create a basic Blazor App, I'm trying to debug the main/start method of my app. Mainly to check the objects I'm injecting and primarily getting the configurations from appsettings.json. I've also ...
Carlo Luther's user avatar
  • 2,452
1 vote
1 answer
2k views

Start-Process passing a hashtable in the ArgumentList

Consider the following situation: Content MyScript.ps1: Param ( [String]$CountryCode, [String]$FilesPath, [String]$KeepassDatabase, [String]$KeepassKeyFile, [String]$EventLog = '...
DarkLite1's user avatar
  • 14.2k
1 vote
1 answer
133 views

How can we trigger the PowerShell file with both another user and admin privileges

I want to launch the file c:\dfs-build.ps1 with the specific user and admin privileges for that I'm trying to use the below command but it's not working. When I'm opening the powershell manually and ...
Lucky_345's user avatar
10 votes
1 answer
18k views

Powershell Start-Process VS Invoke-Item

What's the difference between Start-Process and Invoke-Item? I noticed that you can't Invoke-Item chrome. I assume that Invoke-Item is specifically for files with a given file path. But are there ...
ElliotThomas's user avatar
8 votes
1 answer
5k views

"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 -...
Joe's user avatar
  • 3,837
7 votes
1 answer
817 views

Script calls other script as .ps1 but not as a .exe using ps2exe

$password = ConvertTo-SecureString “Password+++” -AsPlainText -Force $Cred = New-Object System.Management.Automation.PSCredential ("Admin", $password) $FileLocale = Split-Path -Parent -Path $...
Black_n_White's user avatar
7 votes
1 answer
12k views

PowerShell Executing a function within a Script Block using Start-Process does weird things with double quotes

I have a PowerShell script that edits the registry, so it needs to run as admin. To do this, I start up a new PowerShell process from my running PowerShell script, and pass in part of the registry key ...
deadlydog's user avatar
  • 23.5k
4 votes
2 answers
26k views

Running cmd.exe through start-process but unable to pass the command to cmd.exe

I want to run a groovy script with cmd.exe under a different user. I have used Start-Process, when the script gets executed it just opens the prompt on the screen with different user but doesn't ...
Rahul Gupta's user avatar
3 votes
1 answer
17k views

Passing variable arguments using PowerShell's Start-Process cmdlet

Good evening everyone, I'm using a command line that passes arguments to as variables in the following scripts to be run in another ps1 that I'm calling from within this script. Whenever I try to ...
Mike's user avatar
  • 133
3 votes
1 answer
13k views

How to start and stop processes in PowerShell?

This should work fine in PowerShell older than 3. I need to run two processes: wuapp.exe and desk.cpl with ScreenSaver's tab. The problem I have is that once I start wuapp.exe the process name shows ...
ppiotrek's user avatar
3 votes
1 answer
25k views

Executing a scriptblock via startprocess

Would any of you possibly know why this is not working? Start-Process $PSHOME\powershell.exe -ArgumentList "-NoExit -Command & `"{$outvar1 = 4+4; `"out: $outvar1`"}`"" -Wait The ultimate ...
chris's user avatar
  • 243
3 votes
2 answers
3k views

Powershell start-process script calls a second script - how to make one script only

I have a powershell script that accepts parameters in the form of "sender-ip=10.10.10.10" and that runs perfectly with elevated credentials #script.ps1 $userID=$NULL $line_array = @() $multi_array = ...
Glowie's user avatar
  • 2,311
3 votes
2 answers
80 views

PowerShell Start-Process infinite execution of installer

I have Inno Setup installer that run in very silent mode (it's working). But when I'm running my Inno Setup installer through PowerShell script with admin rights – I get endless execution. Also, the ...
Alexandr Kruzer's user avatar
2 votes
1 answer
3k views

Run PowerShell script in PowerShell 6 from C#

I have a PowerShell script which communicates with a REST server. This script only works in PowerShell 6. I want to call it from C#, because the C# program needs the info from the REST server, and I ...
Finni's user avatar
  • 519
2 votes
1 answer
10k views

How to start a 32-bit process in C# without using shell execute on 64-bit machine?

I have an ASP .NET web application on a 64-bit machine that needs to run a legacy 32-bit reporting application. When I run the program with UseShellExecute = false, the program exits with exit code: ...
Ryan's user avatar
  • 2,988
2 votes
1 answer
3k views

PowerShell Script - Run multiple executables in parallel and wait for all launched executables to terminate before proceeding

I have an executable file (.exe) which has to be run multiple times with different arguments in parallel (ideally on different cores) from a PowerShell script, and at the end wait for all launched ...
SimpleThings's user avatar
2 votes
3 answers
940 views

PowerShell, test the performance/efficiency of asynchronous tasks with Start-Job and Start-Process

I'm curious to test out the performance/usefulness of asynchronous tasks in PowerShell with Start-ThreadJob, Start-Job and Start-Process. I have a folder with about 100 zip files and so came up with ...
YorSubs's user avatar
  • 3,582
1 vote
1 answer
316 views

powershell Pipe Operators

I executed the following three powershell commands. The first two commands returned no results, and the third command returned results. The main difference between the three commands is the use of the ...
jiligulu's user avatar
  • 187
1 vote
1 answer
1k views

Starting an executable from a parent directory in PowerShell

I need to start an executable from a parent folder using PowerShell. This is what I have tried: Start-Process -FilePath ..\Tools\MyTool.exe -ArgumentList "MyArgs" -PassThru -NoNewWindow -...
Boris's user avatar
  • 8,773
1 vote
1 answer
5k views

Powershell Silent Install in Nano Server with Docker

My docker file gets a Nano Server container and it adds Java automatically. # Get nano server FROM microsoft/nanoserver # Download file and set in docker container ADD http://javadl.oracle.com/...
user1911's user avatar
  • 680
1 vote
1 answer
1k views

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

I think my problem has a simple solution. But now i'm a bit confused. I have Java Code, that starts 1 Powershell Script. This Powershell Script must start other scripts. Java -> Powershell.ps1 -> ...
Dmytro's user avatar
  • 392
1 vote
1 answer
111 views

Trying to get a command to run in cli from a powershell script but it is picking up an "ambiguous" parameter

I am currently trying to get a command that I know works in CLI to run through a PowerShell Ise script but it will not allow me to run it as it is picking up a part of the command as a parameter. I ...
Callum Cooper's user avatar
1 vote
1 answer
2k views

PowerShell Start-Service Timeout

Problem I have been working on a timeout feature for the Start-Services feature of my application and have stumbled upon some setbacks in which the timeout doesn't work properly or fails to display ...
Brandon's user avatar
  • 761