Using the RMTShare.exe public domain software,
I have scripted DriveLetters.bat to return a local or remote computer's hard disk letters.
The syntax for using DriveLetters.bat is:
DriveLetters ServerName
Where ServerName is the NetBIOS name of the local or remote computer.
The output (DriveLetter:) is displayed on the console, but you can use it in a script:
Microsoft Windows NT-based operating systems assign an
administrative share to every hard disk partition.
for /f "Tokens=*" %%d in ('DriveLetters ServerName') do (
set drive=%%d
call :SomeRoutine
)
DriveLetters.bat contains:
@echo off
If \{%1\}==\{\} @echo Syntax: DriveLetters ServerName&goto :EOF
setlocal
set srv=%1
set srv=\\%srv:\=%
for /f "Tokens=1,2" %%a in ('rmtshare %srv%^|findstr /c:"$"') do (
call :fnd %%a %%b
)
endlocal
goto :EOF
:fnd
set p1=%1
set p2=%2
if /i "%p1:~0,1%" NEQ "%p2:~0,1%" goto :EOF
if "%p1:~1,1%" NEQ "$" goto :EOF
if "%p2:~1,2%" NEQ ":\" goto :EOF
@echo %p2:~0,2%
NOTE: See Computers.bat.