powershell - 从批处理文件调用 Powershell 脚本并在失败时终止
问题描述
我正在尝试在批处理文件中调用 Powershell 脚本
例如。
测试.ps1
function func1(){
#Do something
}
function func2(){
#Do something
}
func1()
func2()
批处理脚本
:: Do something
PowerShell.exe -Command "& {Start-Process PowerShell.exe -ArgumentList '-ExecutionPolicy Bypass -File ""test.ps1""' -Verb RunAs}"
:: Exit execution if powershell execution failed.
如果 powershell 执行遇到任何问题,如何终止批处理文件的执行。
解决方案
推荐阅读
- javascript - 如何使用反应形式使用angular8比较对象数组
- r - 在 dplyr 管道中添加层之前检查 NULL ggplot 对象
- html - 当 display 属性设置为 none 时移除边框
- vue.js - 从 VUEX 存储中的数组中抓取一项
- java - 通过 split(\0) 将 String 转换为 String[] 是否安全?
- logging - 如何在.net core中访问signalr服务器端日志
- windows - 错误代码 0x3 的不同原因是什么?
- asp.net-mvc - 如何将开始表单中的下拉列表值发送到控制器
- bash - 在 bash 变量中保存带空格的路径
- google-cloud-platform - 谷歌部署管理器:DNS。删除 TXT 记录也会删除 A 记录