将一系列DOS命令串在一起可能很棘手,但可以完成或进一步重构。。。
这似乎是做你想做的,或者至少可以用来实现你的最终结果。。。
Workflow showParallel()
{
$t1 = {
cmd /k echo t1 in cmd here...`&pause
}
$t2 = {
cmd /k echo t2 in cmd here...`&pause
}
$t3 = {
cmd /k echo t3 in cmd here...`&pause
}
$tasks = $t1, $t2, $t3
foreach -parallel ($task in $tasks)
{
Start-Process powershell "-noexit `"$task`""
}
}
showParallel
根据OP的请求更新
Workflow showParallel()
{
$name1 = 't1!'
$run1 = "echo $name1 in cmd here..."
$t1 = "
cmd.exe /c '$run1&pause'
"
$t2 = {
cmd /c echo t2 in cmd C here...`&pause
}
$t3 = {
cmd /k echo t3 in cmd K here...`&pause
}
$tasks = $t1, $t2, $t3
foreach -parallel ($task in $tasks)
{
$task
#Start-Process powershell "-noexit -c $task"
Start-Process powershell "-c $task"
}
}
showParallel