1

我一直在尝试重新编写以下 PowerShell 代码,因为我需要它等到完成后再继续,所以假设 Start-Process with -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
}
4

1 回答 1

1

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

Start-Process -FilePath $winrarPath -ArgumentList "a -ep -df `"$saveLocation`" `"$file`"" -Wait
于 2016-07-27T14:28:17.713 回答