---------------
@ECHO OFF
rem Map \\server\folder to the next available drive letter and save
the driveletter as DRIVELETTER
FOR /F "tokens=2" %%A IN ('net use * \\server\folder) DO IF NOT %
%A.==command. SET DRIVELETTER=%%A
rem Unmap DRIVELETTER
net use %DRIVELETTER% /del
rem Clear your env variables
set DRIVELETTER=
---------------
For example... if your next available drive letter was Z... ECHO
%DRIVELETTER% would return "Z:"
enjoy~
> Here's a batch file you can use to map a server to the next available
> drive letter and save that drive letter to a variable.
>
>
Since it hardly ever matters whether "next available drive letter" is
counted from the bottom or top of the alphabet, it's simpler to just let
Windows pick the letter:
for /f "tokens=2" %%A in ('net use * \\server\share ^| find "is now
connected"') do set drive_letter=%%A
(All one line - space between "now" and "connected")
--
T.E.D. (tda...@mst.edu) MST (Missouri University of Science and Technology)
used to be UMR (University of Missouri - Rolla).
In Windows 2000 or higher, PUSHD and POPD are another way to map a server
share temporarily to a drive letter.
http://support.microsoft.com/kb/317379