OK - try this simple mod:
 Code:
===================================================================
; $Function: setDrive
;  $Purpose: Map a drive letter (optionally remove previous)
; ===================================================================
Function setDrive($Letter,$Path,$Desc, $Unmap)

  Dim $UnMapCmd

  If $Debug
    ? ">Mapping "+$Letter+" "+$Path+" ("+$Desc+")"
  Endif

  If $Unmap
    ; Because pre-existing persistent mapped drives are not removed with the below
    ; command, a shell command is used instead
    ;use $Letter /del
    $UnMapCmd = "net use "+$Letter+" /delete /Persistent:no"
    If $Debug
      ? ">Unmap: "+$UnMapCmd
    Endif
    ? " "
    shell $UnMapCmd
    If $UnMap = 2 Exit 0 EndIf
  Endif

  ;use $Letter "$Path"
  Dim $Map
  $Map="net use "+$Letter+" "+chr(34)+$Path+chr(34)+" /persistent:yes"
  shell $Map
 
EndFunction
The changes are simple - instead of recycling the $UnMap variable, we declare $UnMapCmd. That is the command string we execute to unmap if the last argument is NOT ZERO.

The second change is the "If $UnMap = 2 Exit 0 EndIf" line. Now, if the last parameter is 0, it simply maps a drive. If it is 1, it will unmap and then map the new connection. If it is 2, it will unmap the current connection and then exit.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D