删除临时文件的一段脚本

    技术2024-11-07  22

    下面是一段 vbScript 脚本,用于删除指定类型的临时文件,使用时将下列代码存成后缀名为 wsf 的文件

     

     

     

    <!--Autor: Lava_sdb (舒定波)--> <!--Descr: Delete the template File (删除指定的临时文件)--> <Job ID="Delete the template File"> <Script LANGUAGE="VBSCript"> Sub DelTempFiles(folderspec) Dim fso, f, f1, fc, s,foldc,f2 'Add the file type name that you want del Dim Delfiletype() dim typeCout,temptype typeCout=9 ReDim Delfiletype(typeCout) Delfiletype(0)="obj" Delfiletype(1)="pdb" Delfiletype(2)="pch" Delfiletype(3)="res" Delfiletype(4)="bsc" Delfiletype(5)="idb" Delfiletype(6)="ilk" Delfiletype(7)="sbr" Delfiletype(8)="exp" Delfiletype(9)="ncb" ' Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFolder(folderspec) Set fc = f.Files For Each f1 in fc temptype=Right(f1.name,3) dim i for i=0 to typeCout if temptype=delfiletype(i) then f1.delete true 'msgbox f1.name end if next next Set foldc=f.SubFolders For Each f2 in foldc if f.attributes and 2 then else DelTempFiles(f2.path) end if next End Sub </Script> <Script LANGUAGE="JSCript"> var WshShell = WScript.CreateObject("WScript.Shell"); DelTempFiles(WshShell.CurrentDirectory); WScript.Echo(" 临时文件删除完成"); </Script> </Job>

    最新回复(0)