bat文件是dos下的批处理文件。
批处理文件是无格式的文本文件,它包含一条或多条命令。
它的文件扩展名为 .bat 或 .cmd。
在命令提示下输入批处理文件的名称,或者双击该批处理文件,系统就会调用cmd.exe按照该文件中各个命令出现的顺序来逐个运行它们。
使用批处理文件可以简化日常或重复性任务。
制作和使用方法:
1、双击桌面上的“此电脑”》查看》文件扩展名,将其勾选上。

2、右键桌面快捷菜单》新建》文本文档。

3、将文本文档后缀改为BAT。

因为文件类型改变了,所以会出现这个提示,选择“是”。

这时文件变成这样了。

4、鼠标右键选择此文件》编辑,选择记事本打开。


这样我们就可以在里面输入DOS命令了。
例子:
将下面的代码复制到记事本中,这是清理系统垃圾文件的代码。
@echo off
echo 正在清除系统垃圾文件,请稍等......
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mp
del /f /s /q %systemdrive%\*.log
del /f /s /q %systemdrive%\*.gid
del /f /s /q %systemdrive%\*.chk
del /f /s /q %systemdrive%\*.old
del /f /s /q %systemdrive%\recycled\*.*
del /f /s /q %windir%\*.bak
del /f /s /q %windir%\prefetch\*.*
rd /s /q %windir%\temp & md %windir%\temp
del /f /q %userprofile%\cookies\*.*
del /f /q %userprofile%\recent\*.*
del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"
del /f /s /q "%userprofile%\Local Settings\Temp\*.*"
del /f /s /q "%userprofile%\recent\*.*"
echo 清除系统LJ完成!
echo. & pause

保存文件退出。
5、执行
双击这个文本文档即可执行。

本课程是学习BAT文件的制作和执行方法。
DOS命令很多,可以通过百度进行深入学习。