bat批处理文件编写

bat批处理文件:

1新建文本文档,

2输入内容例如

@echo off

echo ----------------------------------

echo       应用教学

echo ----------------------------------

pause

3将文本后缀改为.bat,运行

不过有些人可能会说,双击这些批处理文件总是运行,必须改变文件类型才能编辑,有没有办法把它改成双击编辑呢?别着急,有办法。如下图,打开“运行”,输入“regedit”,按“回车”键,打开注册表编辑器。依次展开HKEY_CLASSES_ROOT\batfile\shell,单击“shell”,在右边的窗口中双击名称为“默认”,类型为“REG_SZ”的二进制(图标为“ab”)项,输入“edit”点击“确定”,然后退出。再打开Windows批处理文件时就能进入编辑了。当右击再点击打开时就可以运行了。

下面是一个windows的清理系统垃圾的bat

@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


猜你喜欢

转载自blog.csdn.net/qq_40475529/article/details/79686576