PowerShell/PowerShellでexitの値を取得する方法・$lastexitcode
の編集
Top
/
PowerShell
/
PowerShellでexitの値を取得する方法・$lastexitcode
[
トップ
] [
編集
|
差分
|
バックアップ
|
添付
|
リロード
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
-- 雛形とするページ --
(no template pages)
#navi(../) * PowerShellでexitの値を取得する方法・$lastexitcode [#c8a0b4e7] PowerShellで書いたスクリプト内のexitの戻り値を取得するには、自動変数である$lastexitcodeを参照すると確認することができます。~ 以下にサンプルスクリプトを記します。 #contents #htmlinsertpcsp(win-top.html,win-sp.html) * 関連記事 [#be6c6e79] -[[PowerShellスクリプトを起動できるようにする>PowerShell/PowerShellスクリプトを起動できるようにする]] -[[PowerShellのバージョンを確認する方法>PowerShell/PowerShellのバージョンを確認する方法・$PSVersionTable]] * $lastexitcodeを使う [#a4caaabc] #ref(exit99.ps1) サンプルスクリプトはexit 99のみを記述したものです。 exit 99 PowerShellを起動し、exit99.ps1を実行し$lastexitcodeを確認してみます。 PS C:\Users\sakura> .\exit99.ps1 PS C:\Users\sakura> $LASTEXITCODE 99 PS C:\Users\sakura> $lastexitcode 99 大文字、小文字のどちらでも確認することができます。 以上、PowerShellでスクリプトが返却するexitの値を取得する方法でした。 //#htmlinsertpcsp(win-btm.html,win-sp.html)
タイムスタンプを変更しない
#navi(../) * PowerShellでexitの値を取得する方法・$lastexitcode [#c8a0b4e7] PowerShellで書いたスクリプト内のexitの戻り値を取得するには、自動変数である$lastexitcodeを参照すると確認することができます。~ 以下にサンプルスクリプトを記します。 #contents #htmlinsertpcsp(win-top.html,win-sp.html) * 関連記事 [#be6c6e79] -[[PowerShellスクリプトを起動できるようにする>PowerShell/PowerShellスクリプトを起動できるようにする]] -[[PowerShellのバージョンを確認する方法>PowerShell/PowerShellのバージョンを確認する方法・$PSVersionTable]] * $lastexitcodeを使う [#a4caaabc] #ref(exit99.ps1) サンプルスクリプトはexit 99のみを記述したものです。 exit 99 PowerShellを起動し、exit99.ps1を実行し$lastexitcodeを確認してみます。 PS C:\Users\sakura> .\exit99.ps1 PS C:\Users\sakura> $LASTEXITCODE 99 PS C:\Users\sakura> $lastexitcode 99 大文字、小文字のどちらでも確認することができます。 以上、PowerShellでスクリプトが返却するexitの値を取得する方法でした。 //#htmlinsertpcsp(win-btm.html,win-sp.html)
テキスト整形のルールを表示する
添付ファイル:
exit99.ps1
643件
[
詳細
]