Ok Lisp Jockeys, need some help on this one. I have some code from Mr. Menzi that lists network paths and remaps network paths. I haven't coded in a while, so ANY help would be extremely appreciated as I am pressed for time (new user coming in tomorrow, and I'm thinking this way is faster than me spending hours on the trial/error method). I'm puting together an app that will check drive mapping and change it accordingly. Here's the parameters:
Jurg Menzi's Code:
VxListNetworkDrives - Returns a list of all mapped network drives with UNC...
;
; -- Function VxListNetworkDrives
; Returns a list of all mapped network drives with UNC path.
; Copyright:
; ©2005 MENZI ENGINEERING GmbH, Switzerland
; Arguments [Typ]:
; --- =
; Return [Typ]:
; > List of mapped drives '(("X:" . "\\\\Server\\Xpath")...) [LIST]
; Notes:
; - Requires ScrRun.dll (see also notes at top of page).
;
(defun VxListNetworkDrives ( / DrvCol ItmCnt RetVal WsnObj)
(setq WsnObj (vlax-create-object "WScript.Network")
DrvCol (vlax-invoke WsnObj 'EnumNetworkDrives)
ItmCnt 0
)
(repeat (/ (vlax-invoke DrvCol 'Count) 2)
(setq RetVal (cons
(cons
(strcase (vla-Item DrvCol ItmCnt))
(vla-Item DrvCol (1+ ItmCnt))
)
RetVal
)
ItmCnt (+ ItmCnt 2)
)
)
(vlax-release-object WsnObj)
(reverse RetVal)
)
Back
VxRemapNetworkDrives - Remaps a network drive to another drive letter
;
; -- Function VxRemapNetworkDrive
; Remaps a network drive to another drive letter.
; Copyright:
; ©2005 MENZI ENGINEERING GmbH, Switzerland
; Arguments [Typ]:
; Old = Old drive letter, eg. "X:" [STR]
; New = New drive letter, eg. "Y:" [STR]
; Return [Typ]:
; > True: Remapping sucessfull
; > False: Remapping failed
; Notes:
; - Requires ScrRun.dll (see also notes at top of page).
;
(defun VxRemapNetworkDrive (Old New / OldUnc RetVal WsnObj)
(setq WsnObj (vlax-create-object "WScript.Network")
OldUnc (cdr (assoc (strcase Old) (VxListNetworkDrives)))
)
(cond
((vl-catch-all-apply
'vlax-invoke
(list WsnObj 'RemoveNetworkDrive Old :vlax-true :vlax-true)
)
)
((vl-catch-all-apply
'vlax-invoke
(list WsnObj 'MapNetworkDrive New OldUnc :vlax-true)
)
)
((setq RetVal T))
)
(vlax-release-object WsnObj)
RetVal
)
Resulting dotted pairs from function to list mapping:
Command: (VxListNetworkDrives)
(("E:" . "\\\\springfield2\\cad") ("G:" . "\\\\lisledc2\\cad") ("H:" .
"\\\\lisledc1\\word") ("I:" . "\\\\lisledc1\\engr") ("J:" .
"\\\\application1\\applications") ("K:" . "\\\\lisledc1\\projects") ("N:" .
"\\\\lisledc2\\tranprojects") ("O:" . "\\\\lisledc2\\office") ("R:" .
"\\\\lisledc2\\communications") ("T:" . "\\\\lisledc1\\temp") ("Y:" .
"\\\\nas2\\archive") ("Z:" . "\\\\lisledc2\\projectscomed") ("X:" .
"\\\\lisledc2\\archive") ("P:" . "\\\\lisledc1\\projects") ("Q:" .
"\\\\lisledc2\\projectscomed") ("S:" . "\\\\lisledc2\\programs"))
I'm only concerned with these two:
("P:" . "\\\\lisledc1\\projects")
("Q:" . "\\\\lisledc2\\projectscomed")
Iterate through the list looking for correct UNC, then grab the CAR and reset it.
Clear as mud?
I'm gonna attempt my HACK mode at this, and see if I can get an answer for myself before anyone else.
The race is ON!