首页 > 解决方案 > 我想创建一个带有选项的批处理文件

问题描述

bat 会询问用户的选项是:

  1. 清理垃圾:
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%
  1. 刷新 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
  1. 获取局域网信息:

ipconfig /all

  1. 网络连接

netstat

  1. 平谷歌:

ping 8.8.8.8

标签: filebatch-file

解决方案


这是完整的批处理文件:

@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

推荐阅读