//-----------------------------------------------------------------------------
//File    : DrivesList.JS
//Purpose : Sample script test for Advanced Host Monitor
//Comment : Checks list of disk drives on local system. Set test's status to 
//          "Bad" when list of drives changes. E.g. when user map/unmap network
//          drive.
//Req     : Test's option "Translate macros" must be enabled
//Language: JScript
//Version : 1.0
//Author  : KS-Soft (www.ks-soft.net)
//-----------------------------------------------------------------------------

statusAlive       = "Host is alive:"
statusDead        = "No answer:"
statusUnknown     = "Unknown:"
statusNotResolved = "Unknown host:"
statusOk          = "Ok:"
statusBad         = "Bad:"
statusBadContents = "Bad contents:"

//---- entry point ----

function performtest()
{
  if ("%Reply%"=="%"+"Reply"+"%") return statusUnknown+"Please enable 'Translate macros' option";
  var CurrList = GetDrivesList();
  if (("%Reply%"!="") && (CurrList!="%Reply%"))  
    return(statusBad+CurrList);  
  else
    return(statusOk+CurrList);
}

//----- functions -----

function GetDrivesList()
{
  var DList="", FSO, Drives;
  FSO = new ActiveXObject("Scripting.FileSystemObject");
  Drives = new Enumerator(FSO.Drives);
  for (; !Drives.atEnd(); Drives.moveNext()) DList = DList + Drives.item().DriveLetter;
  return(DList);
}


function GetCdromDrives()
{
  var DList="", FSO, Drives;
  FSO = new ActiveXObject("Scripting.FileSystemObject");
  Drives = new Enumerator(FSO.Drives);
  for (; !Drives.atEnd(); Drives.moveNext()) 
    if (Drives.item().DriveType == 4) DList = DList + Drives.item().DriveLetter;
  return(DList);
}
