我无法使用 Powershell 脚本直接执行 bat 文件。例如,这在命令行上可以工作:
.\\my-app\my-fle.bat
当我将这个命令添加到脚本中时,它会输出:
The term '.\\my-app\my-file.bat' is not recognized as the
name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.
我还尝试了以下方法,结果是一样的:
& .\\my-app\my-fle.bat
& ".\\my-app\my-fle.bat"
\my-app\my-fle.bat
& \my-app\my-fle.bat
& "\my-app\my-fle.bat"
注意: 它必须返回最后的 exitcode,因为我需要验证批处理的成功。