file - 我想创建一个带有选项的批处理文件
问题描述
bat 会询问用户的选项是:
- 清理垃圾:
del /s /f /q c:\windows\temp\*.*
rd /s /q c:\windows\temp
md c:\windows\temp
del /s /f /q C:\WINDOWS\Prefetch
del /s /f /q %temp%\*.*
rd /s /q %temp%
md %temp%
deltree /y c:\windows\tempor~1
deltree /y c:\windows\temp
deltree /y c:\windows\tmp
deltree /y c:\windows\ff*.tmp
deltree /y c:\windows\history
deltree /y c:\windows\prefetch
deltree /y c:\windows\cookies
deltree /y c:\windows\recent
deltree /y c:\windows\spool\printers
del c:\WIN386.SWP
rd /s /q "c:\windows\prefecth"
md "c:\windows\prefecth"
del /s /f /q c:\windows\temp\*.*
rd /s /q c:\windows\temp
md c:\windows\temp
del /s /f /q C:\WINDOWS\Prefetch
del /s /f /q %temp%\*.*
rd /s /q %temp%
md %temp%
- 刷新 NIC:
pushd\windows\system32\drivers\etc
attrib -h -s -r hosts
echo 127.0.0.1 localhost>HOSTS
attrib +r +h +s hosts
popd
ipconfig /release
ipconfig /renew
ipconfig /flushdns
netsh winsock reset all
netsh int ip reset all
- 获取局域网信息:
ipconfig /all
- 网络连接
netstat
- 平谷歌:
ping 8.8.8.8
解决方案
这是完整的批处理文件:
@echo off
title The title of your program
:menu
cls
echo/
echo Select an option between A-E:
echo/
echo A. Clean junk
echo B. Flush NIC
echo C. Get LAN info
echo D. Network connections
echo E. Ping google
choice /c abcde /n
goto %errorlevel%
:1
Clear junk code here
echo Junk has been cleared.
call :return
:2
Flush NIC code here
echo NIC has been flushed.
call :return
:3
echo LAN info:
ipconfig /all
call :return
:4
echo Network connections:
netstat
call :return
:5
ping 8.8.8.8
call :return
:return
echo/
choice /n /m "Return menu?(Y/N)"
if errorlevel 1 goto menu
exit /b
推荐阅读
- sql-server - 想要在我的日期中获取时间作为 SQL 中 5 的倍数
- c - 在 Struct (C) 中调用不同的函数
- java - Java 不支持枚举上的协变返回类型吗?
- django - 如何使用 django 模型使用 enter 关键字将字符字段逐行保存到数据库中?
- git - 如何打印子模块级别/深度
- delphi - 如何使用文件“映射/共享内存”从我的 Delphi 应用程序中获取 Inno 安装程序“进度状态/日志”
- c# - 如何在 Xamarin Forms 中更改选项卡式页面指示器的颜色
- python - 当字段为 NaN 时,是否有可能在插入字符串时将字段设为空白?
- javascript - Flask + jQuery:线程完成后渲染不同的模板
- javascript - 在 js 中平移和缩放“无限”方格纸背景