1、 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
2、(DirPath)Set subFSO = targetFSO.SubFolders For Each subFolder in SubFSOIf DateDiff(“d“, subFolder.name, date)3 ThenstrPath = DirPathsubFolder.nameobjFSO.DeleteFolder(strPath)End IfNextEnd Function Call DeleteLog( )这样在 task Schdeuler 里面 schedule 我的 vbs 程序就没有报错啦。撒花,结贴 参考代码二:代码如下:Dim dqxs, dqrq, szxs,
3、szfz, dqml, datpDim jclbDim cdim d=datp = “F:“szxs = “7:00:“wjml = datp “DVRDat“sykj = 20000000000 20 个 Gdqml = left(wscript.scriptfullname,instrrev(wscript.scriptfullname,“)-1)jclb = “ServicesManager.exe,PD_Server.exe,SpeedServer.exe,CoreServer.exe,DownloadSVC.exe,ManagerConsole.exe,Gptsvr.exe,Hint
4、AMProxy.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 cprlqldoIf InStr(time, szxs) 0 Thenif fso.GetDrive(datp
5、).FreeSpace sykj then call cprlqlend ifWScript.Sleep(60*1000)loop getfso=fso.GetFolder(“c:windows“).DateCreated=Function cprlqlDim strline, scmlWshShell.run “cmd /c dir “ wjml “ /ad /b /tcc:dir.log“,0if fso.FileExists(“c:dir.log“) thenSet objFile = fso.OpenTextFile(“c:dir.log“) do until objFile.aten
6、dofstreamstrline = objFile.readlinescml = wjml strlineWshShell.run “cmd /c rd /s /q “ scml,0for i = 1 to 20if fso.GetDrive(datp).FreeSpace sykj then exit Functionif fso.FolderExists(scml) thenWScript.Sleep(1000)elseexit forend ifnextif fso.GetDrive(datp).FreeSpace sykj then exit Functionloopend ifEnd Function