【问题标题】:I would like to create a batch file with options我想创建一个带有选项的批处理文件
【发布时间】:2020-04-01 05:34:22
【问题描述】:

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 谷歌:

ping 8.8.8.8

【问题讨论】:

  • Possible duplicate。请解释为什么/如何那里的解决方案不适合您。
  • 您似乎没有提供您的操作系统信息,所以我想我要提一下 deltree 从 Windows XP 开始就没有包含在内。

标签: file batch-file


【解决方案1】:

这是完整的批处理文件:

@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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-26
    • 1970-01-01
    • 1970-01-01
    • 2021-12-28
    • 1970-01-01
    • 1970-01-01
    • 2013-08-31
    相关资源
    最近更新 更多