+ Post New Thread
Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
Scripts Thread, Script to display remaining disk quota in Coding and Web Development; var fso = new ActiveXObject("Scripting.FileSystemObject"); if ( (fso.GetDrive("H:").FreeSpace/fso.GetDrive("H:").TotalSize) < 0.1 ) WScript.Echo("You are approaching your disk quota limit! Blah-blah-blah.."); '--------------- ...
  1. #16

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,896
    Thank Post
    3,418
    Thanked 1,081 Times in 997 Posts
    Rep Power
    369

    Re: Script to display remaining disk quota

    var fso = new ActiveXObject("Scripting.FileSystemObject");

    if ( (fso.GetDrive("H:").FreeSpace/fso.GetDrive("H:").TotalSize) < 0.1 )

    WScript.Echo("You are approaching your disk quota limit! Blah-blah-blah..");

    '--------------- vbscript version ------------

    Dim fso

    Set fso = CreateObject("Scripting.FileSystemObject")

    if((fso.GetDrive("H:").FreeSpace/fso.GetDrive("H:").TotalSize) < 0.1)
    Wscript.Echo("You are approaching your disk quota limit! blah - blah")
    End If


    See if that works for you

  2. #17

    ZeroHour's Avatar
    Join Date
    Dec 2005
    Location
    Edinburgh, Scotland
    Posts
    5,693
    Thank Post
    947
    Thanked 1,355 Times in 828 Posts
    Blog Entries
    1
    Rep Power
    451

    Re: Script to display remaining disk quota

    I am working on a solution involving a client/server approach. Anyone fancy helping in the very early stages add me to MSN and give me a buzz. Not sure on programming languages that I will use but thats kinda to fit the solution then anything. I really need some people to at least run theories past before I implement (and I am to shy to show my foolishness off in forums before thinking it through).

  3. #18
    mortstar's Avatar
    Join Date
    Jan 2007
    Location
    Oxford
    Posts
    341
    Thank Post
    13
    Thanked 29 Times in 18 Posts
    Rep Power
    21

    Re: Script to display remaining disk quota

    I've been reading through a few threads that try to display a dialogue box when quota thresholds are reached on 2k3 R2's File Server Management.

    I have plagiarised a fair few scripts and none seem to do what I need them to.

    The closest I came was the simple script:
    Code:
    Dim fso
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set driveObject = fso.GetDrive("H") 
    
    if((driveObject.AvailableSpace/driveObject.TotalSize) < 0.1) then
    Wscript.Echo("You are approaching your disk quota limit!" & driveObject.FreeSpace)
    else
    Wscript.Echo("fine " & driveObject.AvailableSpace & " " & driveObject.TotalSize)
    End If
    But this is picking up the Used Space and Total Space of the whole network drive, not the quota amount.

    Has anybody created a vbs script that can tell users that they are approaching their quota limit? I'd love to use email notification but it just wouldn't work until we have improved our email solution.

    Failing that - R2 can run a command when the thresholds are reached. The command that is put in this box - is it a file local to the server or to the user's machine? You cannot choose files held on network drives.

  4. #19

    maniac's Avatar
    Join Date
    Feb 2007
    Location
    Kent
    Posts
    3,070
    Thank Post
    210
    Thanked 430 Times in 310 Posts
    Rep Power
    144

    Re: Script to display remaining disk quota

    This little bit of script I've just cobled together from a couple of others.

    It gets the disk size from the windows file system, and then calculates the used space from the size of the folders on the drive. I know it can be simplified, but it works and returns the correct values as a message at the moment.

    I know it's a bit in-accurate on the space used, e.g. it reported 149GB was in use on my test drive, where as windows tells me there's only 146GB, but on smaller quantities of files/folders like a users home area, it should be accurate enough to warn when the quota is low.

    You need to change the TWO referneces to G: to whatever drive letter you're monitoring. I know this can be put in as a variable, but like I say it was cobbled toegther from two seperate scripts.

    Code:
    dim oFS, oFolder
    set oFS = WScript.CreateObject("Scripting.FileSystemObject")
    set oFolder = oFS.GetFolder("G:\")
    
    Set objWMIService = GetObject("winmgmts:")
    Set objLogicalDisk = objWMIService.Get("Win32_LogicalDisk.DeviceID='G:'")
    Wscript.Echo "Space Used=" & int(oFolder.Size /1048576) & " MB" & vbCr & _ 
    "Allowed Space: " & Int(objLogicalDisk.Size /1073741824) & " GB"
    And yes I have tested it with mapped drives limited by windows quotaing, and it works! Also it's not to slow either. On a 160GB network drive it only took about 3 or 4 seconds to calculate the used space, so on a 1GB user share it's not going to be too slow.

    Hope it's of use.

    Mike.

SHARE:
+ Post New Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 5
    Last Post: 16th December 2007, 06:26 PM
  2. Disk quota problem
    By markman in forum Windows
    Replies: 4
    Last Post: 7th December 2007, 11:15 AM
  3. Disk Quota Reporting
    By NeoS in forum Windows
    Replies: 16
    Last Post: 9th July 2007, 06:47 PM
  4. Disk Quota Search
    By alonebfg in forum Windows
    Replies: 5
    Last Post: 1st November 2006, 08:24 PM
  5. Disk Quota
    By BKGarry in forum Scripts
    Replies: 3
    Last Post: 12th October 2006, 07:29 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •