scripting - Powershell 中的 && 等效项

标签 scripting command-line powershell

在 bash 中我使用 ./task1.sh && ./task2.sh运行task1,然后只要task1没有返回错误代码就运行task2。当我尝试 .\task1.bat && .\task2.bat在 Powershell 中,我收到错误“ token && 在此版本中不是有效的分隔符。”

Windows Powershell 中有 && 的等效项吗?

最佳答案

这是我能得到的最接近的:

  .\task1.ps1 ; if($?){.\task2.ps1}

关于scripting - Powershell 中的 && 等效项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6312004/

相关文章:

powershell - 设置环境变量 - SETX

bash - 我如何在 Bash 中解析命令行参数?

python - 在 iTunes 上搜索轨道

linux - 复杂的 shell 通配符

javascript - .env 变量在 React JS 应用程序中返回未定义

powershell - 更新查询中的案例声明

Python、PowerShell 还是其他?

asp.net - 如何切换脚本标签的可见性?

在 C 中读取标志和文件名的命令行参数

linux - 从 shell 脚本中确定 Firefox 是否已呈现页面