Option Explicit Dim iSpc, strComputer, objWMIService Dim fso, fsHandle, MyShell,LogFileName, colItems, objItem Dim strInputFile, objInputFile Const intForReading = 1 strInputFile = "Computers.txt" Set MyShell = CreateObject("Wscript.Shell") Set fso = Wscript.CreateObject("Scripting.FilesystemObject") LogFileName= MyShell.SpecialFolders("Desktop") & "\FreeSpace.txt" set fsHandle = fso.OpenTextFile (LogFileName,8,True) fsHandle.Writeline Date fsHandle.Writeblanklines 1 Set objInputFile = fso.OpenTextFile(strInputFile, intForReading, False) While Not objInputFile.AtEndOfStream strComputer = objInputFile.ReadLine Set objWMIService = GetObject _ ( "winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery _ ("Select * From Win32_LogicalDisk Where DriveType = 3") fsHandle.WriteLine strComputer For Each objItem in colItems 'Retrieve free space & convert from uint64 iSpc = cDbl(objItem.FreeSpace) fsHandle.Writeline objItem.DeviceID & " - " _ & FormatiSpc(iSpc) & " GB free" Next Wend objInputFile.Close Function FormatiSpc(intSpace) intSpace = intSpace/1024 intSpace = intSpace/1024 intSpace = intSpace/1024 intSpace= FormatNumber(intSpace,1) FormatiSpc = intSpace end Function
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE