【问题标题】:Multiple commands in a IF statementIF 语句中的多个命令
【发布时间】:2021-02-12 04:45:20
【问题描述】:

你可以在一个 If 命令中放置多个命令吗? 我所拥有的是查看是否安装了某些东西,如果是,则将文本发送到文件并更改变量。 我的例子是假设你想看看是否安装了边缘...... 设置边=N

If  exist "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"  (
 echo Edge is installed >> C:\Temp\Message.txt
) Else (
echo Edge is Not installed >> C:\Temp\Message.txt
)

如果安装了 Set Edge=Y,我需要把它放在哪里?

【问题讨论】:

    标签: if-statement batch-file


    【解决方案1】:
    If  exist "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"  (
     echo Edge is installed >> C:\Temp\Message.txt
     SET "EDGE=Y"
    ) Else (
    SET "EDGE=N"&echo Edge is Not installed >> C:\Temp\Message.txt
    )
    

    两种方式。

    在带括号的块中,您可以将任意数量的语句放在单独的行中。

    或者,您可以使用& 将多个命令放在一行中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-02
      • 2021-04-24
      • 2021-06-21
      • 1970-01-01
      • 2016-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多