-
1
- #1
jerryr_imported
Programmer
This script is a modification of one of the scripts on Microsoft's script center.
My purpose is to locate all the files that are on a file server whose filesize is zero, and to give me a list of the files. I then review and edit the list then use another script to delete the files remaining in the list.
Everything works fine, except the program is very very slow. It takes over 30 hours to generate the list for a server with about 30 GB of files.
Any suggestions about a better way to do this would be appreciated.
My script follows:
const ForAppending = 2
strComputer = "heserver"
Set objFSO = CreateObject("Scripting.FileSystemObject"
Set objTextFile = objFSO.OpenTextFile ("h:\jwr00892\utils\he_2_zerovbs.log", ForAppending, True)
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2"
Set colFiles = objWMIService. _
ExecQuery("Select * from CIM_DataFile where FileSize = 0 and Hidden <> 'True' and System <> 'True'"
For Each objFile in colFiles
objTextFile.WriteLine(objFile.Name)
Next
objTextFile.Close
My purpose is to locate all the files that are on a file server whose filesize is zero, and to give me a list of the files. I then review and edit the list then use another script to delete the files remaining in the list.
Everything works fine, except the program is very very slow. It takes over 30 hours to generate the list for a server with about 30 GB of files.
Any suggestions about a better way to do this would be appreciated.
My script follows:
const ForAppending = 2
strComputer = "heserver"
Set objFSO = CreateObject("Scripting.FileSystemObject"
Set objTextFile = objFSO.OpenTextFile ("h:\jwr00892\utils\he_2_zerovbs.log", ForAppending, True)
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2"
Set colFiles = objWMIService. _
ExecQuery("Select * from CIM_DataFile where FileSize = 0 and Hidden <> 'True' and System <> 'True'"
For Each objFile in colFiles
objTextFile.WriteLine(objFile.Name)
Next
objTextFile.Close