Author Topic: list of drive letters and names  (Read 1728 times)

0 Members and 1 Guest are viewing this topic.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
list of drive letters and names
« on: February 14, 2014, 02:11:29 PM »
Does anyone know how to get a list of the mapped drives, including drive letter and name?
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ronjonp

  • Needs a day job
  • Posts: 7528
Re: list of drive letters and names
« Reply #1 on: February 14, 2014, 02:16:41 PM »
Here you go :)

Code: [Select]
(defun _getdrives (/ lst sfso)
; IDrive: Drive Interface
; Property values:
;   AvailableSpace (RO) = 1.96325e+011
;   DriveLetter (RO) = "C"
;   DriveType (RO) = 2
;   FileSystem (RO) = "NTFS"
;   FreeSpace (RO) = 1.96325e+011
;   IsReady (RO) = -1
;   Path (RO) = "C:"
;   RootFolder (RO) = #<VLA-OBJECT IFolder 00000000055475a8>
;   SerialNumber (RO) = -458001897
;   ShareName (RO) = ""
;   TotalSize (RO) = 2.49951e+011
;   VolumeName = ""
; No methods
  (if (and (setq sfso (vlax-create-object "Scripting.FilesystemObject"))
   (vlax-for x (vlax-get-property sfso 'drives) (setq lst (cons x lst)))
      )
    (progn (vlax-release-object sfso) (reverse lst))
  )
)
;; (mapcar '(lambda (x) (vlax-get x 'driveletter)) (_getdrives))
« Last Edit: February 14, 2014, 02:22:03 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: list of drive letters and names
« Reply #2 on: February 14, 2014, 02:36:12 PM »
Perfect! Thank you, Ron.

Code: [Select]
(mapcar
  (function
    (lambda (x)
      (list (vlax-get x 'DriveLetter)
            (vlax-get x 'ShareName)
      )
    )
  )
  (_getDrives)
)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ronjonp

  • Needs a day job
  • Posts: 7528
Re: list of drive letters and names
« Reply #3 on: February 14, 2014, 02:43:27 PM »
:) Glad to help.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: list of drive letters and names
« Reply #4 on: February 14, 2014, 02:52:36 PM »
:) Glad to help.
Very appreciated. I figured it would have to be with the FileSystemObject, but I am horrible at digging through that data.  :ugly:
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox