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

首頁 > 編程 > VBScript > 正文

vbs 定時刪除功能實現代碼

2020-07-26 11:46:59
字體:
來源:轉載
供稿:網友

參考代碼一:

復制代碼 代碼如下:

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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 西青区| 昭苏县| 遂宁市| 西丰县| 哈尔滨市| 垫江县| 五常市| 三江| 龙口市| 巴塘县| 商南县| 华池县| 北京市| 固安县| 隆化县| 房山区| 新兴县| 咸宁市| 湖南省| 信丰县| 商水县| 砀山县| 石楼县| 衡南县| 宽城| 贡嘎县| 唐山市| 陇川县| 潮州市| 靖州| 清河县| 铁岭县| 剑川县| 昭通市| 文昌市| 喀喇沁旗| 金阳县| 会泽县| 阿城市| 济阳县| 宝丰县|