VBS timed deletion function implements code _vbs

Source: Internet
Author: User

Reference Code One:

Copy Code code as follows:

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 ()
So in the task Schdeuler inside schedule My VBS program there is no error. Sprinkle flowers, knot paste ~ ~

Reference Code two:

Copy Code code as follows:

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
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
Todo
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.