如果通过命令提示符运行但不在脚本中运行命令..?(Command works if run through the command prompt but not in a script..?)

编程入门 行业动态 更新时间:2024-10-28 18:35:39
如果通过命令提示符运行但不在脚本中运行命令..?(Command works if run through the command prompt but not in a script..?)

我正在尝试使用批处理文件编写许多补丁的安装脚本,因为PowerShell没有正确安装补丁。 我正在运行的命令是这样的:

dism /online /add-package /PackagePath:"C:\<path>\5cbb03ca-7a2a-4326-952f-80ad8052a886\windows6.1-kb2836942-x64-express.cab"

直接从命令行运行时,这非常有效。 但是,如果我把它放在一个名为example.bat的文件中,它将失败并显示以下消息:

'þd' is not recognized as an internal or external command

I'm trying to script the installation of a number of patches using a batch file since powershell doesn't properly install the patches. The command I'm running is this:

dism /online /add-package /PackagePath:"C:\<path>\5cbb03ca-7a2a-4326-952f-80ad8052a886\windows6.1-kb2836942-x64-express.cab"

That works perfectly when run directly from the command line. But if I put it in a file called example.bat it fails with the following message:

'þd' is not recognized as an internal or external command

最满意答案

我认为您的批处理文件保存为Unicode。

在记事本中重新打开它并重新保存,确保编码字段设置为ANSI。

I think your batch file is saved as Unicode.

Re-open it in Notepad and re-save it, making sure the Encoding field is set to ANSI.

更多推荐

本文发布于:2023-08-03 02:56:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1383205.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   命令提示符   命令   Command   works

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!