【问题标题】:Trying to create a title using user input in batch尝试使用用户输入批量创建标题
【发布时间】:2015-06-26 00:43:21
【问题描述】:

尝试批量命名 cmd 窗口,但使用用户输入...

@echo off
Title Something Smart Here
Color 07

:start
cls
set /p command=

if %command% == title goto title

:title
cls
title %command%

真的需要帮助,我希望用户输入命令所以

"Title" "the title here"
^^command   ^^Title

【问题讨论】:

    标签: batch-file command echo title


    【解决方案1】:

    因此您可以通过仅测试第一个单词来将用户输入解析为命令:

    @echo off
    Title Something Smart Here
    Color 07
    
    :start
    cls
    set /p c=
    
    for /f %%a in ("%c%") do (
      if "%%a"=="title" goto title
    goto start
    )
    
    :title
    cls
    %c%
    

    本质上,如果用户输入title [text],它会将标题更改为[text],然后程序继续运行。输入任何其他内容,它会再次提示您。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-01-17
      • 2017-04-08
      • 1970-01-01
      • 2019-06-08
      • 2017-09-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多