vbs 定時(shí)刪除功能實(shí)現(xiàn)代碼
參考代碼一:
Function DeleteLog( )
Dim objFSO, objFolder, strPath, targetFSO, subFSO, DirPath
DirPath = createobject("Scripting.FileSystemObject").GetFile(Wscript.ScriptFullName).ParentFolder.Path&"\Log\"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set targetFSO = objFSO.GetFolder(DirPath)
Set subFSO = targetFSO.SubFolders
For Each subFolder in SubFSO
If DateDiff("d", subFolder.name, date)>3 Then
strPath = DirPath&subFolder.name
objFSO.DeleteFolder(strPath)
End If
Next
End Function
Call DeleteLog( )
這樣在task Schdeuler里面schedule我的vbs程序就沒(méi)有報(bào)錯(cuò)啦。撒花,結(jié)貼~~
參考代碼二:
Dim dqxs, dqrq, szxs, szfz, dqml, datp
Dim jclb
Dim c
dim d
'=========================================================
datp = "F:"
szxs = "7:00:"
wjml = datp & "\DVRDat\"
sykj = 20000000000 '20個(gè)G
dqml = left(wscript.scriptfullname,instrrev(wscript.scriptfullname,"\")-1)
jclb = "ServicesManager.exe,PD_Server.exe,SpeedServer.exe,CoreServer.exe,DownloadSVC.exe,ManagerConsole.exe,Gptsvr.exe,HintAMProxy.exe,FileServer.exe,CleanDisk.exe,GetNetData.exe,SGUClient.exe,SGUServer.exe,"
set WshShell = WScript.CreateObject("WScript.Shell")
Set fso = Wscript.CreateObject("Scripting.FileSystemObject")
'=========================================================
if fso.GetDrive(datp).FreeSpace < sykj then call cprlql
do
If InStr(time, szxs) <> 0 Then
if fso.GetDrive(datp).FreeSpace < sykj then call cprlql
end if
WScript.Sleep(60*1000)
loop
getfso=fso.GetFolder("c:\\windows").DateCreated
'===========================================================
Function cprlql
Dim strline, scml
WshShell.run "cmd /c dir " & wjml &" /ad /b /tc>c:\dir.log",0
if fso.FileExists("c:\dir.log") then
Set objFile = fso.OpenTextFile("c:\dir.log")
do until objFile.atendofstream
strline = objFile.readline
scml = wjml & strline
WshShell.run "cmd /c rd /s /q " & scml,0
for i = 1 to 20
if fso.GetDrive(datp).FreeSpace > sykj then exit Function
if fso.FolderExists(scml) then
WScript.Sleep(1000)
else
exit for
end if
next
if fso.GetDrive(datp).FreeSpace > sykj then exit Function
loop
end if
End Function
相關(guān)文章
使用 Iisftpdr.vbs 刪除FTP虛擬目錄(支持本地與遠(yuǎn)程)
這篇文章主要介紹了如何通過(guò) iisftpdr.vbs 刪除本地或遠(yuǎn)程計(jì)算機(jī)上的 FTP 虛擬目錄的方法,需要的朋友可以參考下2014-07-07
VBS實(shí)現(xiàn)GB2312,UTF-8,Unicode,BIG5編碼轉(zhuǎn)換工具
VBS寫的GB2312,UTF-8,Unicode,BIG5編碼轉(zhuǎn)換工具,轉(zhuǎn)換工具下載:GB2Ue.vbs (3.34 kb)2010-06-06
用vbs確定計(jì)算機(jī)是否有 USB 2.0 端口的代碼
用vbs確定計(jì)算機(jī)是否有 USB 2.0 端口的代碼...2007-03-03
使用 Iisext.vbs 刪除 Web 服務(wù)擴(kuò)展文件的方法
這篇文章主要介紹了如何使用 iisext.vbs 從本地或遠(yuǎn)程計(jì)算機(jī)上刪除 Web 服務(wù)擴(kuò)展文件,需要的朋友可以參考下2014-07-07
文件夾定時(shí)自動(dòng)備份 AutoBackUpFolder.vbs
定時(shí)自動(dòng)備份文件夾到一個(gè)以時(shí)間命名的新目錄,設(shè)置好后加到啟動(dòng)項(xiàng)里,只要一啟動(dòng)機(jī)器程序就會(huì)自動(dòng)運(yùn)行,占系統(tǒng)資源可以不計(jì)。2009-07-07

