標籤:bat常用指令碼工具
整理下日常windows上用的比較多幾個命令工具指令碼。
一、刪除目錄及目錄下的所有檔案
@echo on
cd /D E:\test
for /R %%s in (.,*) do rd /q /s %%s\建立檔案夾
exit
rem 刪除一個目錄下的所有指定的檔案夾
二、自動壓縮後刪除
@echo off
xcopy d:\Inetpub\4FWeb\* D:\Inetpub\taosf.bak\ /s
cd \
cd c:\program files
cd winrar
Rar.exe a -ag -r -m5 -df d:\DB_back\hjl_taosf.rar D:\Inetpub\taosf.bak\
pause
三、自動對應共用盤
@echo off
net use y: \\192.168.22.80\資訊部 [email protected] /user:it /persistent:yes
rem [email protected]是密碼,user:it 登入名稱是it persistent自動的?
四、重啟iis
@echo off
net stop iisadmin /yes
net start iisadmin
net start w3svc
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mp
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\*.*
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\*.*"
exit
五、刪除指定天以前的檔案
@echo off
::需要Win2003/Vista/Win7系統內建的forfiles命令的支援
rem 指定待刪除檔案的存放路徑
set SrcDir=F:\RECORD
rem 指定天數
set DaysAgo=90
rem forfiles /p %SrcDir% /s /m *.* /d -%DaysAgo% /c "cmd /c del /f /q /a @path"
forfiles /p %SrcDir% /s /m *.* /d -%DaysAgo% /c "cmd /c del /f /q /a @path"
for files /p %SrcDir% /m /d -%DaysAgo% /c " if @ISDIR==TRUE rd /s /q @PATH"
pause
windows實用指令碼