Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过从另一个powershell文件调用来并行运行powershell文件?_Powershell_Parallel Processing_Multiprocessing - Fatal编程技术网

如何通过从另一个powershell文件调用来并行运行powershell文件?

如何通过从另一个powershell文件调用来并行运行powershell文件?,powershell,parallel-processing,multiprocessing,Powershell,Parallel Processing,Multiprocessing,我有File1.ps1,它需要并行调用File2.ps1和File3.ps1,它们必须在不同的窗口中打开。你知道我该如何做到这一点吗 启动进程和其他命令似乎不起作用。尝试设置要执行的每个文件,同时启动计划任务。我对它进行了测试,发现这两个窗口同时出现并执行 $filePath = "C:\path\to\files" $fileList = ".\File2.ps1", ".\File3.ps1" $startTime = (get-date).AddMinutes(1) foreach ($

我有File1.ps1,它需要并行调用File2.ps1和File3.ps1,它们必须在不同的窗口中打开。你知道我该如何做到这一点吗


启动进程和其他命令似乎不起作用。

尝试设置要执行的每个文件,同时启动计划任务。我对它进行了测试,发现这两个窗口同时出现并执行

$filePath = "C:\path\to\files"
$fileList = ".\File2.ps1", ".\File3.ps1"
$startTime = (get-date).AddMinutes(1)

foreach ($file in $fileList) {
    Register-ScheduledTask `
        -Trigger (New-ScheduledTaskTrigger -Once -At $startTime) `
        -Action (new-scheduledtaskaction -execute "powershell.exe" -argument "-noexit -file $filePath\$($file.TrimStart('.\'))") `
        -TaskName "Execute-$($file.Split(".\")[2])" `
        -TaskPath Microsoft\Windows\PowerShell\ScheduledJobs `
        -Principal (New-ScheduledTaskPrincipal -LogonType Interactive -UserId $env:USERDOMAIN\$env:USERNAME -RunLevel Highest)

}

尝试使用作业系统。请看一个很好的例子。启动过程到底是如何不起作用的?示例:启动进程-FilePath powershell.exe-ArgumentList@-NoExit,-命令,File2.ps1。但启动进程不会按顺序而不是并行运行吗?@user3325210我修改了我的答案。您是正确的,我发布的原始答案将按顺序执行每个启动过程。