You could also examine the result of the use statement, it returns the drive
letter used, using stdout.
Joe
sDriveLetter = FreeDrive()
MsgBox sDriveLetter
Function FreeDrive
Dim I, oFso
Set oFso = CreateObject("Scripting.FileSystemObject")
For I = Asc("F") to Asc("U")
If Not oFso.DriveExists(Chr(I)) Then
Freedrive = Chr(I) & ":"
Exit Function
End If
Next
End Function
--
Michael Harris
Microsoft.MVP.Scripting
--
Quote:
> Hi
> If Bryan Martin's solution with a hardcoded drive letter (Z:) is not an
option,
> but you want to have the drive letter dynamicly assigned (using "net
use"), you
> can at delete time enumerate through all "networked" drive letters and
find the
> one that is mapped to \\remotemachine\share. Then you can use
> Network.RemoveNetworkDrive <drive_letter_found> or "net use
<drive_letter_found>
Quote:
> /d"
> Alternativly, to dynamicly assigned drive letters using
Network.MapNetworkDrive,
Quote:
> you can enumerate existing drive letters and let your script find the next
free
> one to use. You will then know which one to delete later.
> --
> torgeir
> > Hello all,
> > I am mapping a driver using the following
> > Shell.Run "net use /user:domain\username * \\remotemachine\share
password"
> > I however need to delete the mapped driver after I am done with it but I
can
> > not figure out how to get the drive letter it uses.
> > My question is Is there a way to get the drive letter (maybe the Drives
> > collection????) so I can use a "net use %driverletter% /d"
> > any help is much appreciated