杂门技术windows运维

Windows:批处理工具 .bat 以及常用 .bat 工具文

2020-10-21  本文已影响0人  dex0423

每个 100s 清理一下 temp 文件夹

@echo off
color 0a
:loop
echo Delete TEMP Files Every 100s ...
del /f /s /q %userprofile%\AppData\Local\Temp\*.*
cd %userprofile%\AppData\Local\Temp
rd /s /q %userprofile%\AppData\Local\Temp
echo finished time %date% %time%
echo Wait For 100s ...
@ping 127.0.0.1 -n 100 >nul
goto loop

注意:
-- /f 强制删除只读文件;
-- /s 从所有子目录删除指定文件;
-- /q 安静模式,删除时不要求确认;

批量清理系统垃圾

@echo off 

color 0a

del /f /s /q C:\Windows\WinSxS\Backup

del /f /s /q %userprofile%\AppData\Local\Microsoft\Windows\INetCache\IE\H3PI6GKG\*.*

del /f /s /q %userprofile%\AppData\Local\Microsoft\Windows\INetCache\IE\RYUGFFZ7\*.*

del /f /s /q %userprofile%\AppData\Local\Microsoft\Windows\INetCache\IE\TWNYUZTO\*.*

del /f /s /q %userprofile%\AppData\Local\Google\Chrome\User Data\Profile 1\Cache\*.*

del /f /s /q %userprofile%\AppData\Local\Microsoft\Windows\INetCache\IE\7D90CVER\*.*

del /f /s /q C:\Windows\LiveKernelReports\*.*

RD %windir%\$hf_mig$ /Q /S 

dir %windir%\$NtUninstall* /a:d /b >%windir%\2950800.txt 

for /f %%i in (%windir%\2950800.txt) do rd %windir%\%%i /s /q 

echo Delete TEMP files ...

del /f /s /q %userprofile%\AppData\Local\Temp\*.*
cd %userprofile%\AppData\Local\Temp
rd /s /q %userprofile%\AppData\Local\Temp

del %windir%\KB*.log /f /q 

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 /s /q "%userprofile%\local settings\temporary internet files\*.*" 

del /f /s /q "%userprofile%\local settings\temp\*.*" 

del /f /s /q "%userprofile%\recent\*.*" 

打开 cmd 窗口执行 python 文件

echo off
python 要执行的python文件名.py
pause

.bat 连接 mongo 数据库

echo off
mongo xxx.xxx.xxx.xxx:27017/admin -u MongoDB账户名 -p MongoDB密码
pause

.bat 连接 redis 数据库

echo off
echo INPUT :  "auth winterisfire" TO AUTH 
redis-cli -h xxx.xxx.xxx.xxx -p 6379
pause
echo off
redis-cli -h xxx.xxx.xxx.xxx -p 6379
pause
上一篇 下一篇

猜你喜欢

热点阅读