vbscript

vbscript function: check if drive is mapped

  1. ' great example function to check for drive mappings and echo status
  2. ' to console. Note: this function requires the following
  3.  
  4. set fso = CreateObject("Scripting.FileSystemObject")
  5.  
  6. function IsDriveMapped (byval drive)
  7. ' use only the letter, and not any appending :
  8. ' also and make sure it's uppercase
  9. drive = ucase(left(drive,1))
  10. ' assume it's not mapped
  11. IsDriveMapped = False
  12. ' if no such drive, return False right now
  13. if not fso.DriveExists(drive) then exit function
  14. wscript.echo drive & ":\ drive is currently mapped"
  15. ' get Drive object and check its type: 3 = mapped
  16. isDriveMapped = (fso.GetDrive(drive).driveType = 3)
  17. end function
Syndicate content