WScript: Get Email when disk space low

Yesterday, Mick Genie come out a script to generate the free space from your computer, and it might useful for you for certain purpose.

However, I have think off if this is very inconvenience if you need to login to the computer for every time.

Hence I have come out another script to use IIS SMTP server to send an email to you when the disk space is low.

Set objMessage = CreateObject(“CDO.Message”)
objMessage.Subject = “Disk Space Alert: ServerName”
objMessage.From = “Disk Space Alert<Disk Space Alert>”
objMessage.To = “[email protected]

Dim objShell, space_value, Result
Set objShell = Wscript.CreateObject(“WScript.Shell”)

Set DiskSet = GetObject(“winmgmts:{impersonationLevel=impersonate}”).ExecQuery (“select * from Win32_LogicalDisk where DriveType=3″)
For each Disk in DiskSet
If (Disk.Name=”D:”) Then
Result = Disk.FreeSpace
End If
space_value = Result
Wscript.echo space_value
if space_value < 30 then

objMessage.TextBody = “Server Disk Space Low, ” & space_value & ” GB”
objMessage.Configuration.Fields.Item (“”) = 2
objMessage.Configuration.Fields.Item (“”) = “”
objMessage.Configuration.Fields.Item (“”) = 25

end if

You need to change the Subject, From, To, Email IP, and port only.

Note: This script tested only work with 32bits box, but not 64 bits box.  Save this file to anyname.vbs will do.

Published by

Mick Genie

Mick Genie is the founder of and working at ExaBytes Network Sdn Bhd and WPWebHost web host company. He is expertise in Windows and Linux environment especially web hosting related information, tips and trick as well as the IT Information.