嗨,我發現,這與下面的代碼片段一些奇怪的行爲
function test
{
$LASTEXITCODE = $null
ping asdfs
Write-Host "Last exitcode: $LASTEXITCODE"
}
test
Write-Host "Last exitcode: $LASTEXITCODE"
從這個輸出是
Ping request could not find host asdfs. Please check the name and try again.
Last exitcode:
Last exitcode: 1
爲什麼$ LASTEXITCODE不設置內test()函數?
這是我遇到現在的問題泛化,當我調用一個Win32 .EXE從功能和$ LASTEXITCODE內沒有返回,我在一個函數中期待值
謝謝你,完全是有道理的。 – blue18hutthutt