![]() ![]() Note: There is a limit to the size of variables. At other times I need to process a json file to load just a value into a variable. This is useful when writing batch scripts where the return value from one program is used as input for another program. Now you can just replace the line Echo Not enough free space with a command to send you an alert via email. Often I need to load the content of a file into a Windows Command Prompt variable. This is how the "wmic" command in this script calls the logicaldisk space and places it into the FreeSpace variable. In the script, WMIC is the Windows Management Instrumentation (WMI) component of Windows that comes with an assortment of commands you can use to pull information from your PC. echo offįor /f "usebackq delims= tokens=2" %%x in (`wmic logicaldisk where "DeviceID='C:'" get FreeSpace /format:value`) do set FreeSpace=%%x To create a script that compares the current free hard drive space to your limit, you'll have to create the following batch script and save it as a. The local variable only exists within the file of defining it or in a section of that. ![]() If it's below 3GB, you want to get an email report that says "Hard Drive Space Too Low." I read more the accepted solutions than what the OP wanted, sorry. One of the basic things you'll usually need to do in a batch script is compare two values and follow a different course of action depending on the comparison.įor example, let's say you want to write a batch script that checks your computer's hard drive size daily. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |