gpt4 book ai didi

batch-file - Windows批处理文件错误: ( was unexpected at this time

转载 作者:行者123 更新时间:2023-12-02 20:07:32 25 4
gpt4 key购买 nike

这是我的 run.bat 文件:

set var1 = %1
IF %var1%=="Yes" (
Echo deleting filename.txt
) ELSE (
Echo The file was not found.
)

我运行它的方式如下:run.bat -h 我收到此错误:

C:\Users\admin\Desktop\test>run.bat -h

C:\Users\admin\Desktop\test>set var1 = -h
( was unexpected at this time.

C:\Users\admin\Desktop\test>IF =="Yes" (

最佳答案

您在没有 %1 参数的情况下运行了它。

在命令行中运行:

run.bat something

不仅仅是

run.bat

为了避免这种情况,您必须对 %var1% 使用引号,以使 IF 正常工作:

set "var1=%1"
IF "%var1%"=="Yes" (
Echo deleting filename.txt
) ELSE (
Echo The file was not found.
)

然后你就可以在没有参数的情况下运行它,它不会提示。

关于batch-file - Windows批处理文件错误: ( was unexpected at this time,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54320838/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com