C#运行Powershell脚本异步

时间:2015-12-07 11:07:59

标签: c# powershell

我尝试使用以下方法运行powershell脚本:

>    PowerShellInstance.AddScript(
>                     @"write-output balls;Start-Sleep -s 2;write-output balls;Start-Sleep -s 2;write-output balls;Start-Sleep -s 2");

这样可以正常工作,但以下情况并非如此。有什么想法吗?

   PowerShellInstance.AddScript(
                    @"c:\folder\script.ps1");

1 个答案:

答案 0 :(得分:-1)

这就是为什么......

PowerShellInstance.AddScript(
                    @"& ""c:\folder\script.ps1""");