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.
255 questions
7
votes
1 answer

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 path using a Script Block with a function in it.…
deadlydog
  • 22,611
  • 14
  • 112
  • 118
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
7
votes
3 answers

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 on server, so i'm connect with PSSession (No…
Servuc
  • 328
  • 1
  • 4
  • 16
7
votes
5 answers

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) $String = "This is string number" $Scriptblock =…
atownson
  • 368
  • 2
  • 10
  • 22
6
votes
1 answer

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 $MyInvocation.MyCommand.Definition Write-Output…
6
votes
1 answer

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 stderr to the first terminal. Not trying to make…
Soleil
  • 6,404
  • 5
  • 41
  • 61
6
votes
1 answer

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 error: Access is denied Here is the full error…
John-Philip
  • 3,392
  • 2
  • 23
  • 52
6
votes
4 answers

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 command, and also with taskmgr in the remote…
Colyn1337
  • 1,655
  • 2
  • 18
  • 27
5
votes
2 answers

Remotely zipping files with PowerShell start-process and invoke-command

I want to be able to remote into a system and zip or unzip files there and have the process signal when it is complete. Start-process works with the -wait parameter to run 7z.exe synchronously from PowerShell. When I try to combine that with…
What Would Be Cool
  • 6,204
  • 5
  • 45
  • 42
5
votes
1 answer

Process.start does not find file when useshellexecute = false

I need to call batch-files from my UWP Application. The way to do seems to be Process.Start(), but it says it does not find the file even tough it is definitly there when I follow the path it outputs. Filepath and Working Directory are both given…
Mika
  • 75
  • 5
5
votes
5 answers

Powershell Start-Process msiexec on a remote machine not working

For some reason Start-Process msiexec won't work when run through invoke command on a remote machine. I looked it up and while some people recommend using psiexec i have seen a lot of people using the plain old invoke-command to start msi installers…
4
votes
5 answers

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-ENU.msi"; Is there any reason I am missing? Note I…
Diego
  • 16,436
  • 26
  • 84
  • 136
4
votes
1 answer

How to change priority of process in powershell, if it runs with -Wait parameter?

I am using a scheduled PowerShell script to start the same process with various arguments many times in a loop. Process is very heavy on computations and runs for a long time, and I have thousands of iterations. I noticed, that since it's a…
miguello
  • 544
  • 5
  • 15
4
votes
2 answers

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 console application (creating a process, running…
lysergic-acid
  • 19,570
  • 21
  • 109
  • 218
4
votes
2 answers

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 process the $command. So my question is "How to pass…
Rahul Gupta
  • 201
  • 2
  • 4
  • 10
1
2
3
16 17