PowerShell 片段:
Import-Module Pscx
Expand-Archive ConsoleApplication1.zip ./
Write-Host $?
Write-Host $LastExitCode
既不$?
也不$LastExitCode
报告错误。但是有错误,因为文件 ConsoleApplication1.exe 被锁定(我启动了这个应用程序)。我可以通过以下输出看到失败:
WARNING: ArchiveCallBack->GetStream error: System.IO.IOException:
The process cannot access the file 'D:\tmp\ConsoleApplication1.exe'
because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
...
问题:如何在 powershell 中检测 Expand-Archive 失败
谢谢