Start-Process -wait doesn't work when script is launched from command prompt opened with runas or as a scheduled task

最后都变了- 提交于 2019-12-01 03:25:21

Can't tell you why it's doing it, but I think this might work around it:

$proc = Start-Process -FilePath "C:\Pfx Engagement\Admin\Utilities\Backup Restore\BackupRestoreUtil.exe" -ArgumentList "/f "$backup_directory"" -Passthru
do {start-sleep -Milliseconds 500}
until ($proc.HasExited)

The -Passthru switch will make it return a Process object for the process, and you can test that to see when the process has exited.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!