Announcement

Collapse
No announcement yet.

drive space notification

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • drive space notification

    With this script I want to have a notification of when the D: drive is smaller than 2 gigs. I have pretty much everything right except for specifying which drive to use. Here is what I got.

    Const CONVERSION_FACTOR = 1048576
    Const WARNING_THRESHOLD = 200000
    Computer = "computer name"
    Set objWMIService = GetObject("winmgmts://" & Computer)
    Set colLogicalDisk = objWMIService.InstancesOf("Win32_LogicalDisk")
    For Each objLogicalDisk In colLogicalDisk
    FreeMegaBytes = objLogicalDisk.FreeSpace / CONVERSION_FACTOR
    If FreeMegaBytes < WARNING_THRESHOLD Then

    objMessage.Subject = "Low Drive Space!!"
    objMessage.From = "[email protected]"
    objMessage.To = "[email protected]"
    objMessage.TextBody = "DRIVE SPACE IS BELOW 2 GIGS!!!"
    objMessage.Send

    End If
    Next

  • #2
    Re: drive space notification

    I think you would want to use something like:

    If objLogicalDisk.DriveLetter = "D" THEN ....


    Tom
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

    ** Remember to give credit where credit is due and leave reputation points where appropriate **

    Comment


    • #3
      Re: drive space notification

      Ok I tried using something like that and I got an error saying this..

      Object doesn't support this prperty or method: "objLogicalDisk.DriveLetter'

      Here's my code:

      Const CONVERSION_FACTOR = 1048576
      Const WARNING_THRESHOLD = 1500000
      Computer = "COMPUTER NAME"
      Set objWMIService = GetObject("winmgmts://" & Computer)
      Set colLogicalDisk = objWMIService.InstancesOf("Win32_LogicalDisk")
      For Each objLogicalDisk In colLogicalDisk
      If objLogicalDisk.DriveLetter = "D" THEN

      FreeMegaBytes = objLogicalDisk.FreeSpace / CONVERSION_FACTOR
      else
      end if

      If FreeMegaBytes < WARNING_THRESHOLD Then

      msgbox "test has worked"

      else
      end if

      next

      Comment


      • #4
        Re: drive space notification

        Try this:

        http://www.microsoft.com/technet/scr.../stdvvb10.mspx
        Server 2000 MCP
        Development: ASP, ASP.Net, PHP, VB, VB.Net, MySQL, MSSQL - Check out my blog http://tonyyeb.blogspot.com

        ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

        Comment


        • #5
          Re: drive space notification

          I actually found the right command for it, its:

          If objLogicalDisk.DeviceID = "D" THEN
          So I put that in but im getting a continuous message box of the "test has worked." How do I get this to stop?

          Comment


          • #6
            Re: drive space notification

            I found another way to do it, this will work:

            Option Explicit

            Dim getFSO, getDrive
            Dim getFreeSpace, getszDriveLetter
            Set getFSO = CreateObject("Scripting.FileSystemObject")
            getszDriveLetter = "C:"
            Set getDrive = getFSO.GetDrive(getszDriveLetter)
            getFreeSpace = getDrive.AvailableSpace/1000000

            If getFreeSpace < 2000 Then
            Wscript.Echo "Drive Space is Below 2 GIGS!"
            Else
            End If

            Comment


            • #7
              Re: drive space notification

              Good solution, Ekrengel
              Tom Jones
              MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
              PhD, MSc, FIAP, MIITT
              IT Trainer / Consultant
              Ossian Ltd
              Scotland

              ** Remember to give credit where credit is due and leave reputation points where appropriate **

              Comment

              Working...
              X