【问题标题】:Batch File toggle menus批处理文件切换菜单
【发布时间】:2015-08-30 22:07:41
【问题描述】:

我目前正在编写一个批处理文件,我想制作一个切换菜单以供选择执行,而不是执行常见的问题和答案

有什么方法可以列出选择并为它们切换“运行”或“关闭”,然后按 Enter 开始

我找到了一个似乎让我朝着正确方向前进的文件,但我不知道如何使它与我的批处理文件一起工作

我找到的代码是……

@echo off

set _on=0

:top
cls

if %_on%==0 (set _nlb= &set _nrb= &set _flb=[&set _frb=]) else (set _nlb=    [&set _nrb=]&set _flb= &set _frb= )

echo The '_on' flag is currently: %_nlb% On %_nrb%  %_flb% Off %_frb%
echo.
echo Press any key to toggle the '_on' flag
pause>nul

if %_on%==0 (set _on=1) else (set _on=0)
goto top

我喜欢它看起来像

netusers [run] [off]
netuseradministrator [run] [off]
virus.exe [run] [off]
press enter to initiate selected.

如果有意义的话,在那种类型的布局中

【问题讨论】:

  • 想要的选项列表对您来说还不够吗?例如:1. netusers - 2. netuseradministrator - 3. virus.exe - set /P "list=Enter the list of desired processes: "
  • 或者menus in batch file中提出的方法。看起来你正在编写一个批处理文件来攻击计算机。

标签: batch-file cmd


【解决方案1】:

使用选择命令。例如

echo 1] Settings
echo 2] Start
echo 3] Quit
choice /c 123 /n
if %errorlevel%==1 goto settings
if %errorlevel%==2 goto start
if %errorlevel%==3 goto quit

还有更多的超时参数和类似的东西。看choice /?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-11-28
    • 1970-01-01
    • 1970-01-01
    • 2013-12-18
    • 1970-01-01
    • 1970-01-01
    • 2019-04-17
    • 2012-12-18
    相关资源
    最近更新 更多