使用 bat 脚本调用 powershell 脚本时遇到的问题
如果 powershell 脚本中,有一些涉及相对路径的操作,会发现这样运行的 powershell 并不是在期望的目录中,需要重新设置一下当前工作目录:
powershell -Command Set-Location -LiteralPath "%cd%"; ".\test.ps1"
通过 Set-Location 命令即可实现此需求。
参考:https://stackoverflow.com/questions/69404268/how-to-change-the-current-directory-using-bat-file-in-windows-powershell
输了你,赢了世界又如何...