home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Data 2004 February / CD Rom Data Şubat 2004.iso / Media / Internet / host-mon.exe / Examples / Scripts / DiskSpaces.js < prev    next >
Encoding:
Text File  |  2002-10-22  |  1.2 KB  |  41 lines

  1. //-----------------------------------------------------------------------------
  2. // File    : DiskSpaces.JS
  3. // Purpose : Sample script test for Advanced Host Monitor
  4. // Comment : Checks difference between free disk space on drive C: and drive D: 
  5. //           Sets status to "Bad" when drive C: has less amount of free space 
  6. //           than drive D:
  7. // Language: JScript
  8. // Version : 1.0
  9. // Author  : KS-Soft (www.ks-soft.net)
  10. //-----------------------------------------------------------------------------
  11.  
  12. statusAlive       = "Host is alive:"
  13. statusDead        = "No answer:"
  14. statusUnknown     = "Unknown:"
  15. statusNotResolved = "Unknown host:"
  16. statusOk          = "Ok:"
  17. statusBad         = "Bad:"
  18. statusBadContents = "Bad contents:"
  19.  
  20. //---- entry point ----
  21.  
  22. function performtest()
  23. {
  24.   var deltaspace;
  25.   deltaspace = availablespace("C:\\") - availablespace("D:\\");
  26.   if (deltaspace >= 0)
  27.      return(statusOk + deltaspace/1024 + " K");
  28.   else
  29.      return(statusBad + deltaspace/1024 + " K");
  30. }
  31.  
  32. //----- functions -----
  33.  
  34. function availablespace(drvPath)
  35. {
  36.   var fso, d;
  37.   fso = new ActiveXObject("Scripting.FileSystemObject");
  38.   d = fso.GetDrive(fso.GetDriveName(drvPath));
  39.   return(d.AvailableSpace);
  40. }
  41.