国产探花免费观看_亚洲丰满少妇自慰呻吟_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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 桐城市| 深泽县| 子洲县| 修武县| 界首市| 襄汾县| 刚察县| 汾阳市| 疏勒县| 湄潭县| 石景山区| 甘南县| 宁强县| 乌海市| 故城县| 祁东县| 高台县| 南开区| 华宁县| 乡城县| 泰宁县| 侯马市| 临漳县| 崇州市| 湖北省| 汝阳县| 搜索| 陆丰市| 盘山县| 柘荣县| 黔西县| 比如县| 灯塔市| 遂川县| 赤峰市| 洛川县| 揭阳市| 嘉峪关市| 洛南县| 沁水县| 株洲县|