In your code, where you have:
Code:

Function MapDrive($Drive, $Server, $Share)
Dim $Drive, $Server, $Share, $shell



You need to change it to:
Code:

Function MapDrive($Drive, $Server, $Share)
Dim $Server, $Share, $shell



The problem is that the Function uses $Drive as a variable being passed to the Function and it does not need to be re-dimmed.

HTH,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's