1
votes

I have been trying to re-write the following PowerShell code as I need it to wait until completion before carrying on so assumed Start-Process with -Wait would be sufficient however I can't seem to get it to actually run...

Original code which works, but won't wait until it's finished before carrying on with the script.

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

My attempt at re-writing which isn't running as expected, does nothing so far...

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

1 Answers

1
votes

Fixed with the following... knew it was something silly.

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