首页脚本vbs 定时删除功能实现代码

vbs 定时删除功能实现代码

时间2024-02-11 16:30:03发布访客分类脚本浏览403
导读:收集整理的这篇文章主要介绍了vbs 定时删除功能实现代码,觉得挺不错的,现在分享给大家,也给大家做个参考。 参考代码一:复制代码 代码如下:Function DeleteLOG( ...
收集整理的这篇文章主要介绍了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

您可能感兴趣的文章:
  • php定时删除文件夹下文件(清理缓存文件)
  • 使用mysql事件调度器定时删除binlog
  • 使用vbs脚本定时删除N天前的文件
  • Windows和Linux下定时删除某天前的文件的脚本
  • Shell定时删除指定时间之前的文件
  • 定时删除一个文件夹内的所有子文件夹和文件的方法

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!


若转载请注明出处: vbs 定时删除功能实现代码
本文地址: https://pptw.com/jishu/610041.html
Wscript 和 Cscript 运行脚本的区别详解 vbs脚本实现批量转换文件编码

游客 回复需填写必要信息