Micah
Micah

Reputation: 116140

Launch non-blocking process from powershell

I'm writing a powershell script that needs to push code to several git repositories simultaneously?

Here's the script I have thus far:

param(
    [parameter(Mandatory=$true)]
    [string]$repoPath,
    [parameter(Mandatory=$true)]
    [array]$remoteRepos
)

pushd $repoPath
$remoteRepos | % { 
    #Want to exexcute this without blocking
    & git push $_ master --fore -v 
}
popd

Here's how I execute the script:

gitdeploy.ps1 -repoPath c:\code\myrepo -remoteRepos repo1,repo2

How to I execute the & git push $_ master --fore -v in a way that is non-blocking?

SOLUTION

Thanks to @Jamey for the solution. I wound executing this command:

Start-Process "cmd.exe" "/c git push $_ master --force -v"

Upvotes: 9

Views: 8205

Answers (3)

Brad
Brad

Reputation: 3530

How about start git "push $_ master --force -v"

Upvotes: 0

Jamey
Jamey

Reputation: 1633

You can also use start-process to run each push in an additional command window.

start-process -FilePath "git" -ArgumentList ("push", $_,  "master", "--fore", "-v") 

Upvotes: 10

Chintana Wilamuna
Chintana Wilamuna

Reputation: 866

Micah, you can use start-job to run it in background - http://technet.microsoft.com/en-us/library/dd347692.aspx

Upvotes: 3

Related Questions