下面是我创建的批处理文件,列出了8个可能的选项供用户选择要查看的信息(菜单全部混乱,但编码正确)。
@ECHO OFF
:MENU
echo
echo Press CTRL + C to exit at any time
echo
echo 1. attrib- Displays all the attributes of all files in the current directory
echo 2. cipher- Displays encryption state of current folder and any files it contains
echo 3. hostname- Displays the host name portion of the full computer name
echo 4. ipconfig- Displays IPv4 and IPv6 addresses, subnet mask, and default gateway
echo 5. netstat- Active TCP connections(a), ethernet statistics(e),port numbers (n)
echo 6. getmac- Returns media access control address and list of network protocols
echo 7. path- Displays current command path
echo 8. tasklist- Displays list of currently running processes on the local computer
echo
echo
set /p T=Enter your choice:
IF %T% == 1 goto attrib
IF %T% == 2 goto cipher
IF %T% == 3 goto hostname
IF %T% == 4 goto ipconfig
IF %T% == 5 goto netstat
IF %T% == 6 goto getmac
IF %T% == 7 goto path
IF %T% == 8 goto tasklist
:attrib
attrib | more
goto MENU
:cipher
cipher | more
goto MENU
:hostname
hostname | more
goto MENU
:ipconfig
ipconfig | more
goto MENU
:netstat
netstat -a -e -n | more
goto MENU
:getmac
getmac | more
goto MENU
:path
path | more
goto MENU
:tasklist
tasklist | more
goto MENU
:End
我想知道如何提供大量信息的命令可以在一个单独的命令shell中运行,输出通过寻呼机传输(本质上更多命令),并且在这个新命令窗口中也有一个合适的标题。
例如,菜单中的ipconfig选项显示了很多信息,我希望在新的命令窗口中使用|更多命令。
答案 0 :(得分:1)
start "ipconfig" cmd /c "(ipconfig.exe /all | more)&pause"
确保管道在生成的cmd实例中执行,过滤ipconfig
的输出,而不是在当前实例管道中start
命令的输出