Windows PowerShell Exit Codes
2024-09-04 17:30:39
Windows PowerShell Exit Codes
PSMDTAG:FAQ: How can my script control the PowerShell exit code?
Answers:
- A normal termination will set the exitcode to 0
- An uncaught THROW will set the exitcode to 1
- The EXIT statement will stop the process and set the exitcode to whatever is specified.
c:\>powershell -noprofile -command "Write-output Test"
Test
c:\>echo %errorlevel%
0
c:\>powershell -noprofile -command "Write-output Test; throw 'ERROR'"
Test
ERROR
At line:1 char:25
+ Write-output Test; throw <<<< 'ERROR'
c:\>echo %errorlevel%
1
c:\>powershell -noprofile -command "Write-output Test; exit 31492"
Test
c:\>echo %errorlevel%
31492
Jeffrey Snover [MSFT]
Windows PowerShell/MMC Architect
Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at
http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
最新文章
- hibernate 异常:Unexpected Exception caught setting
- 中文乱码~Windows 7
- Android笔记——探究活动
- Tiffany
- 【题解】【字符串】【Leetcode】Valid Palindrome
- 【转】java 自动装箱与拆箱
- php正则过滤html标签、空格、换行符的代码,提取图片
- C#使用.net.mail配置163邮箱报错:不允许使用邮箱名称。 服务器响应为:authentication is required,smtp9,DcCowABHK4UYE11W2k6fAQ--.52196S2 1448940312
- 文本去重-----awk或者uniq
- 【mongodb系统学习之四】查看mongodb进程
- hystrix服务降级(3)
- vue 移动端屏幕适配 使用rem
- 给HTML页面指定元素添加属性,添加父元素
- Debian 9 VIM 使用鼠标右键复制
- CMake系列之四:多个源文件-多个目录
- jQuery选择器--:selected和:checked
- Spring源码解析二:IOC容器初始化过程详解
- ios网络请求
- java提取url里的域名
- Android应用自动更新功能的实现!