国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > VBScript > 正文

vbs 定時刪除功能實現代碼

2020-06-26 18:36:32
字體:
來源:轉載
供稿:網友
這篇文章主要介紹了vbs 定時刪除功能實現代碼,需要的朋友可以參考下
 

參考代碼一:

復制代碼代碼如下:

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程序就沒有報錯啦。撒花,結貼~~ 

 

參考代碼二:

 

復制代碼代碼如下:

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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 大宁县| 阜城县| 永福县| 田林县| 沂南县| 晴隆县| 龙海市| 鹤峰县| 五台县| 洛浦县| 泗洪县| 镇雄县| 岳阳县| 金昌市| 广河县| 新安县| 崇阳县| 万山特区| 浙江省| 乌拉特中旗| 普定县| 昌都县| 兰考县| 阿拉尔市| 仪陇县| 洛南县| 古蔺县| 调兵山市| 乐东| 安国市| 平罗县| 邢台市| 凤阳县| 乡宁县| 莱州市| 荔波县| 宝应县| 临桂县| 合阳县| 库车县| 大庆市|