WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: kle2 on April 28, 2022, 05:14:55 AM

Title: disk usage
Post by: kle2 on April 28, 2022, 05:14:55 AM
I am trying to get the disk usage (C: D: E: etc...) remotely (or at least locally) for Windows servers.  Do you have any suggestion/command?  Thank you - Khoa
Title: Re: disk usage
Post by: ChuckC on April 28, 2022, 06:05:46 AM
WMI [Windows Management Instrumentation] can be utilized in a WinBatch script.  Specifically, the class Win32_LogicalDisk can provide the information that you're looking for.  WMI can access both the local computer and remote computers, provided that the remote computers are configured to allow inbound requests to interact with WMI.

I'd recommend first searching the tech support database for articles about using WMI from WinBatch, do some reading and try out some of the script code in those articles.  Demonstrate to yourself that you can make it work.  Then adapt that code to specifically query a computer for all instances of Win32_LogicalDisk, iterate through them and obtain the desired information from each instance.
Title: Re: disk usage
Post by: kle2 on April 28, 2022, 06:59:21 AM
Thanks for your suggestion, Chuck!  I found the reference code.  Khoa

https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsrch.web+~+TechHome
Title: Re: disk usage
Post by: td on April 28, 2022, 07:18:01 AM
WinBatch also has the "DiskFree" function which reports the amount of unused disk space. You can find more information in the functions documentation in the Consolidated WIL Help file. The "Diskscan" function will obtain a list of drive letters.
Title: Re: disk usage
Post by: kle2 on April 28, 2022, 08:57:29 AM
Thank you, TD!