![]() ![]() The user just needs to follow your script name with the parameters defining their personal file path. For example, let’s say you’ve written a script that that performs an xcopy command from an input folder, to a common network folder used by a team. Now you can just replace the line “Echo Not enough free space” with a blat email command to send you an alert.Ĭheck for Missing Parameters The last useful IF statement isn’t a specific command, but instead to check that the script received the appropriate input parameters. This is how the “wmic” command in this script calls the “logicaldisk” space and places it into the FreeSpace variable. ) WMIC is the Windows Management Instrumentation component of Windows that comes with an assortment of commands you can use to pull PC information. off set DriveLimit=300000000 for /f 'usebackq delims tokens=2'%%x in (`wmic logicaldisk where 'DeviceID='C:' get FreeSpace /format:value`) do set FreeSpace=%%x Echo FreeSpace='%FreeSpace%' Echo Limit='%DriveLimit%' If%FreeSpace% GTR%DriveLimit% ( Echo There is enough free space. If it’s below 3 GB you want to get an email report that says, “Hard Drive Space Too Low.” To create a script that compares the current free hard drive space to your limit, you’d create the following batch script and save it as a.bat file. For example, let’s say you wanted 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 |