Replace TargetLabel with what you are naming your USB Flash drives and try something like this:
Main Topics
Browse All TopicsLong story short, I would like to boot winpe and have it always assign the usb thumb drive to be drive letter T:\. We are using WinPe booting off of usb thumb drives as part of our imaging process. Originally I setup the imaging scripts to be drive letter E:\ on all the thumb drives, now with tablets, I had to go back in and set those to be drive letter D:\ (since they do not have cd rom drives). If the pc's have hidden restore partitions winpe assigns the usb thumb drive to letter F: or G:. Thus we have to manually go into Diskpart, select volume, assign letter=E, etc..
I am working on some batch files to do a
diskpart, list volume, pipe that into text file or another command to (this is where I am stuck) then select the removable volume and eventually assign letter=T.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
In WinPe, it did not like the Findstr, changed, set TargetLabel=Removable, and added, echo %USBVol%
echo %OldLetter%
echo %USBLabel%
then it worked like a charm each time, maybe a timing issue.
Final script
@echo off
setlocal
set TargetLabel=Removable
set TargetLetter=T
echo list volume > %Temp%\DiskPart1.txt
echo exit >> %Temp%\DiskPart1.txt
for /f "tokens=2-4" %%a in ('diskpart.exe /S %Temp%\DiskPart1.txt ^| find /I "%TargetLabel%"') do (
set USBVol=%%a
set OldLetter=%%b
set USBLabel=%%c
)
echo Drive with label "%USBLabel%" is "Volume %USBVol%" and currently assigned drive %OldLetter%:
echo %USBVol%
echo %OldLetter%
echo %USBLabel%
echo select volume %USBVol% > %Temp%\DiskPart2.txt
echo assign letter=%TargetLetter% >> %Temp%\DiskPart2.txt
echo exit >> %Temp%\DiskPart2.txt
diskpart.exe /S %Temp%\DiskPart2.txt
echo Drive letter of "%TargetLabel%" should now be %TargetLetter%:
pause
Saved it as setusb2t.cmd
Next test will be to add it to the winpe image and have it launch automatically with startnet.cmd.
Thank you for all your help!!!
Business Accounts
Answer for Membership
by: Shift-3Posted on 2009-02-06 at 10:04:46ID: 23572244
You can get the letter of the drive that the batch script is running on with the variable %~d0. See here for more information.
You could then use this to generate a diskpart script or a subst command. For instance, the command below temporarily maps the T: drive to the script's drive.
Select allOpen in new window