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
4
votes
1 answer

Convert string to PSCustomObject

The problem I'm having stems from passing a PSCustomObject as an argument to the Start-Process cmdlet (I'm essentially starting a new PowerShell process to run a script asynchronously from the calling script). Although the parameter is defined as…
Harry
  • 197
  • 3
  • 16
4
votes
4 answers

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 provide a string argument list which won't cut it…
Kirk Liemohn
  • 7,733
  • 9
  • 46
  • 57
4
votes
1 answer

Elevate creditals with powershell via Local System Account

I want to deploy code using powershell via Jenkins Job. This works fine in the powershell ise. $username = "mydomain\builder" $password = "notmypassword" $credentials = New-Object System.Management.Automation.PSCredential -ArgumentList…
paul rockerdale
  • 377
  • 6
  • 21
4
votes
1 answer

Powershell Start-Process ignored in remote session

I am starting a new process using: $removeArguments = "-Command `"&{import-module .\deploy-utility.psm1; RemoveSolutions -solutionNames $solutionNames -url $url;}`"" start-process powershell -ArgumentList $removeArguments -Wait This works fine…
3
votes
1 answer

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 purpose for this is so that i can run a script block as…
chris
  • 233
  • 2
  • 3
  • 6
3
votes
2 answers

How to hide the CMD console from this code?

How to hide the console from within this code? Currently the cmd console is shown everytime I run this code. protected override void OnStart(string[] args) { String applicationName = "cmd.exe"; // launch the application …
karikari
  • 6,627
  • 16
  • 64
  • 79
3
votes
1 answer

powershell.exe start-process -About "\" when using the Verb option

Thank you for your help. I use Powershell in the Windows 10 command prompt and try to execute commands with administrative rights. When I try the following three, a, b and c, I cannot start with "RunAs" as I think. Does anyone know how to solve this…
aroma
  • 33
  • 2
3
votes
0 answers

Installer behavior: BAT vs PS Start-Process

I am seeing some odd behavior running the installer for Autodesk 3D Studio Max 2021. The key issue with an Autodesk installer is it is actually a staged installer, you launch an EXE, which reads data from some XML files, and launches a number of…
Gordon
  • 6,257
  • 6
  • 36
  • 89
3
votes
0 answers

Start-Process "msiexec.exe" failing when powershell executed from msi package

Start-Process "msiexec.exe" -arg "/a $MsiPath /qn TARGETDIR=$TargetDirectory" This line is part of powershell script of msi(say a.msi). While running a.msi it would call the above script, which is expected to extract contents of b.msi($Msipath) to…
Rem San
  • 367
  • 1
  • 5
  • 20
3
votes
1 answer

Start-Process powershell cannot find specified

Edit5: Adam's code works unless there are spaces in the path. That solution is at Powershell Opening File Path with Spaces Edit4: Simplified further with a test for the path. Same Error. If ($args[0] -eq "admin") { $TheScriptPath =…
Logan Jones
  • 324
  • 1
  • 3
  • 10
3
votes
2 answers

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 scripts isn't known ahead of time and needs to be…
3
votes
2 answers

Start-Process / System.Diagnostics.Process ExitCode is $null with -NoNewWindow

The Powershell cmdlet Start-Processis acting weirdly: When I launch another console process and I specify -NoNewWindow, the ExitCode property (an int!) is null. Here's a test: Same with something else besides cmd. This test was on a Win10 with PS5,…
Martin Ba
  • 37,187
  • 33
  • 183
  • 337
3
votes
1 answer

How to use install parameters and -wait while running an .exe

I want to install SQLServer2014SP1 and then SQL Data Tools. I need it to wait for SP1 to complete before installing SQL Data Tools. Here's what I've been trying: Write-Host "Launching SQL SP 1 ..." Start-Process…
jdope
  • 115
  • 2
  • 14
3
votes
2 answers

PowerShell: Start-Process Firefox, how do he know the path?

When I call the following code: Start-Process Firefox Then the PowerShell opens the browser. I can do that with several other programs and it works. My question is: How does the PowerShell know which program to open if I type Firefox? I mean, Im…
user5197928
3
votes
1 answer

Task scheduler PowerShell Start-Process is not running

I have this simple script on Windows 10, which works fine when just executing, but fails to start notepad when running from task scheduler. Stop-Process works perfectly, Start-Process does not run. When I run it on demand, it closes the notepad and…
Jaanus
  • 16,161
  • 49
  • 147
  • 202
1 2
3
16 17