从运行PowerShell脚本BAT文件最安全的方法 [英] Safest way to run BAT file from Powershell script
本文介绍了从运行PowerShell脚本BAT文件最安全的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不能让一个PowerShell脚本直接执行一个bat文件。例如,这个工作在命令行上:
\\\\我的应用\\ MY-fle.bat
当我加入这个命令的脚本,它输出:
术语\\\\我的应用\\ MY-file.bat'不是公认的
命名cmdlet,函数,脚本文件或可操作的程序的。
检查名称的拼写,或者如果路径包括,
验证路径是否正确,然后再试一次。
我也试过以下,具有相同的结果:
&安培; \\\\我的应用\\ MY-fle.bat
&安培; \\\\我的应用\\ MY-fle.bat
\\我的应用\\ MY-fle.bat
&安培; \\我的应用\\ MY-fle.bat
&安培; \\我的应用\\ MY-fle.bat
请注意:它必须为我需要验证一批成功返回lastexit code
。解决方案
的cmd.exe / c'\\我的应用\\ MY-file.bat
I can not get a powershell script to execute a bat file directly. For example, this works on the command line:
.\\my-app\my-fle.bat
When I add this command to a script, it outputs:
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.
I also tried the following, with the same result:
& .\\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"
Note: It must return the lastexitcode as I need to verify success of batch.
解决方案
cmd.exe /c '\my-app\my-file.bat'
这篇关于从运行PowerShell脚本BAT文件最安全的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文