[Moderator (Sealeopard): Moved thread from 'General' to 'Scripts' forum]
I am attempting to re-map existing network drives on windows machines. I need to set the existing drive letter to a variable and then use that variable in conjunction with two others as the parameters in the USE command. Below is a copy of my code. I can not get the existing drive to be deleted nor the new drive to be mapped.
;Calls Windows Host Scripting function to enumerate drives
Function WshEnumDrives()
Dim $fso
$WshEnumDrives = ""
$fso = CreateObject("scripting.filesystemobject")
If $fso
$WshEnumDrives = $fso.drives
EndIf
Exit @error
EndFunction
;Loops through enumerated drives and determines drive letter, type of drive and Share Name
For Each $drive in WshEnumDrives()
If $drive.drivetype = "3"
$w=InStr($drive.sharename,"med1")
If $w=0
Goto end
EndIf
$v="\\med1\home\"
$x=Left($drive.drivetype,1)
$y=SubStr($drive.sharename,8)
$z=$drive.driveletter
? $y
? $z
If Exist ($v+$y)
use $z: /del /persistent
Use $z: $v+$y
If @error = 0
Goto end
Else
MessageBox("You do not have the correct permissions to map a drive to "+$v+"\"+$y+". If you believe you should have access to this folder, please notify your business manager.","Folder not accessible",16)
EndIf
EndIf
EndIf
:end
Next
[ 18. December 2002, 21:24: Message edited by: sealeopard ]
_________________________
"When fascism comes to America, it will be wrapped in the flag, carrying a cross."
Sinclair Lewis