我正在执行下面的7 Zip命令,这个命令大约需要3-4个小时才能完成,然后使用$lastexitcode确保压缩成功。这样做对吗?我发现$lastexitcode并不总是0,但是压缩文件看起来很好。
还会有什么东西在修改这个出口代码吗?
& $7z a -tzip -mx=1 $destinationdir\$today.zip $destinationdir\$db1 >$null 2>&1
if ($lastexitcode -ne 0){
...$null 2>&1‘>只是被使用,所以我看不到7 zip的输出.
谢谢你的帮助。
发布于 2017-04-06 08:57:15
我通常使用另一种方法,比如:
$process = Start-Process notepad.exe -PassThru -Wait 然后使用
$process.ExitCode试试这个:
$process = Start-Process $7z -PassThru -Wait -ArgumentList "a -tzip -mx=1 $destinationdir\$today.zip $destinationdir\$db1 >$null 2>&1"
if ($process.ExitCode -ne 0) { ....}https://stackoverflow.com/questions/43250124
复制相似问题