Sunday, February 13, 2011

Retrieving Drive Letters through Batch Files

The task to be discussed today is retrieving already occupied drive letters in Windows. Of course, through batch scripting. This batch file is quite small and simple, and after its execution you can see all the letters on the screen. Of course, you can easily change this batch file.

@echo off
setlocal enabledelayedexpansion
echo list volume>"%temp%\ds.txt"
for /f "skip=8 tokens=3" %%a in ('diskpart /s "%temp%\ds.txt"') do set "used=!used! %%a"
del /q "%temp%\ds.txt" 2>nul
echo The used letters are - %used:~1%

Hope this batch file will be really useful for you.

No comments:

Post a Comment

Translate