启动进程不是 运行

Start-Process not running

我一直在尝试重写以下 PowerShell 代码,因为我需要它等到完成后再继续,所以假设使用 -Wait 启动进程就足够了,但我似乎无法真正做到运行...

原始代码有效,但不会等到完成后再继续脚本。

function ZipAndDeleteFile([string] $file, [string] $saveLocation)
{
    $command = [string]::Format("`"{0}`" a -ep -df `"$saveLocation`" `"$file`"", $winrarPath);
    iex "& $command";
}

我的重写尝试没有 运行 预期的那样,到目前为止什么也没做...

function ZipAndDeleteFile([string] $file, [string] $saveLocation)
{
    Start-Process -FilePath $winrarPath -ArgumentList "a -ep -df $saveLocation $file" -Wait
}

修复了以下内容...知道这很愚蠢。

Start-Process -FilePath $winrarPath -ArgumentList "a -ep -df `"$saveLocation`" `"$file`"" -Wait