从Powershell启动非阻塞过程 [英] Launch non-blocking process from powershell
本文介绍了从Powershell启动非阻塞过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写一个Powershell脚本,该脚本需要同时将代码推送到几个git存储库中?
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
如何以非阻塞方式执行& git push $_ master --fore -v
?
How to I execute the & git push $_ master --fore -v
in a way that is non-blocking?
解决方案
感谢@Jamey提供解决方案.我很想执行此命令:
Thanks to @Jamey for the solution. I wound executing this command:
Start-Process "cmd.exe" "/c git push $_ master --force -v"
推荐答案
您还可以使用启动过程在其他命令窗口中运行每次推送.
You can also use start-process to run each push in an additional command window.
start-process -FilePath "git" -ArgumentList ("push", $_, "master", "--fore", "-v")
这篇关于从Powershell启动非阻塞过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文