Win32::GetNextAvailDrive() is a good start, unless you really need to mount the E: drive. Mounting a specific letter would probably be bad form if more than one machine is using ths script, especially when you're using such a low letter.
THANKS SO MUCH FOR THIS CODE BIT! I've wanted this for a while, but never had the motivation to find it! Now I'll never have to put in my password 10 times each time I log in using Win2K!
Update: The AddConnection() will fail if the drive letter is already used. So, you can do the ol' trial-and-error check at least to see if it's in use. Disconnecting may be tougher, though. I can't find anything on that so far.
Update2: Duh.. It was right in front of my face.
From
perldoc Win32::NetResource:
CancelConnection($Name,$Connection,$Force)
Cancels a connection to a network resource connected to local device $
+name. $Connection is either 1 - persistent connection or 0, non-pers
+istent.