1.

Solve : How to determine what drive a USB would be on?

Answer»

How would you determine what drive a USB would be on? Because the drive can vary depending on the computer. you want to do this in batch?
Yes. If it's not possible that's understandable. i think it COULD be possible...give me a second...i'll whip up a script.ok here's the script:

just put the batch file in the USB drive and it will get the Drive letter of the USB drive:
Code: [SELECT]@echo off
title GetDrive Letter
cd > temp.tmp
set /p return=<temp.tmp
set parentdrive=%return:~0,1%
del temp.tmp
echo The Drive letter of this USB Drive is: %parentdrive%
pause
Hope this Helps
,Nick(macdad-)i dont know if you have wmic but here it is
Code: [Select]C:\Users\_CORE>wmic volume get DriveType,Name
DriveType Name
3 C:\
3 F:\
3 D:\
3 E:\
5 G:\
2 H:\
i think that DriveType 2 is USB and 3 is SCSI Quote from: macdad- on March 03, 2009, 06:57:47 AM

ok here's the script:

just put the batch file in the USB drive and it will get the Drive letter of the USB drive:
Code: [Select]@echo off
title GetDrive Letter
cd > temp.tmp
set /p return=<temp.tmp
set parentdrive=%return:~0,1%
del temp.tmp
echo The Drive letter of this USB Drive is: %parentdrive%
pause
Hope this Helps
,Nick(macdad-)

why not use for loop ?

Code: [Select]for /f %%a in ('echo %cd%') do set var=%%a
set var=%var:~0,3%
echo %var%should of thought of that, either will do.Of course . Maybe I should think these things through.


Discussion

No Comment Found