1.

Solve : need a command that tests for a drive letter?

Answer»

im trying to write a batch file that writes a file to a usb pen drive

im looking for a dos command that will identify the first existing drive letter after the D Drive (CDROM)

I am aware that you can set the drive letter of the usb STICK in Disk Management but in my experience i have seen drive letter change from E to F for unknown reasons

There maybe no files on the usb stick so i cannot use the IF EXIST command

is there a dos command for this or a way to code it in a batch file?

TIA

SethHere are the steps you will NEED to assign a permanent drive letter to a thumb drive.
http://mintywhite.com/tech/vista/assign-a-permanent-letter-to-a-usb-thumb-drive-2/
Hope this is what you really wanted
mm, thats kind of what i mentioned in my original post abouting using Disk management.
The thing is, my CUSTOMER is going to be using multiple USB sticks (its for a daily backup routine)
ive seen them put in one stick and it comes up E then a few weeks later the same stick will come up as F drive
also if they buy a new stick i dont want them to have to go down the route of assigning drive letters etc as they are not that technical.I also know of a backup program that detects when a usb drive is inserted and performs an automatic backup. I bought it for a friend a while back. Forget the name off hand but it's out there. Why reinvent the wheel. I BELIEVE this is it.
http://www.backupusb.com/
Quote

There maybe no files on the usb stick so i cannot use the IF EXIST command

IF exist will find the root folder.
Consider changing your way of thinking on how to resolve your problem and use the MS DOS command "MOUNTVOL" as follows. In this example certain commands have been "remmed" out for safety.

rem By using the "MOUNTVOL" command USB drives used as backup-to-disk targets
rem can be either removed or PLUGGED back in.
rem By using the "NET SHARE" command USB drives may be shared out to users.

c:
cd C:\windows\system32\

cls
@echo.
@echo.

rem This command displays both the details of the corresponding Volume Names and Paths
@echo on
call mountvol.exe
@echo off

@echo.
@echo.
pause

rem ***************
cls
@echo.
@echo.

rem These commands removes the "volume mount point" from the "specified directory"
@echo on
rem This commands removes the drive letter F: from the USB device name
rem mountvol.exe F: /D
rem This commands removes the drive letter G: from the USB device name
rem mountvol.exe G: /D
@echo off

@echo.
@echo.
pause

rem ***************
cls
@echo.
@echo.

rem This command displays both the details of the corresponding Volume Names and Paths
@echo on
call mountvol.exe
@echo off

@echo.
@echo.
pause

rem ***************
cls
@echo.
@echo.

rem These commands assign the "volume mount point" to the "individual directory"
rem Should you be required to use the "volume mount point" for different USB Drives
rem You can mountvol different "individual directory" so long as there is only 1
rem USB drive plugged in at once.
@echo on
rem mountvol.exe F: \\?\Volume{f90aec0d-a238-11dd-8bd4-001c23d69c2e}\
rem mountvol.exe F: \\?\Volume{10badd33-a9b2-11dd-a3fc-001c23d69c2e}\
rem
rem mountvol.exe G: \\?\Volume{10badd33-a9b2-11dd-a3fc-001c23d69c2e}\
@echo off

rem F:\ = \\?\Volume{f90aec0d-a238-11dd-8bd4-001c23d69c2e}\
rem G:\ = \\?\Volume{10badd33-a9b2-11dd-a3fc-001c23d69c2e}\

@echo.
@echo.
pause

rem ***************
cls
@echo.
@echo.

rem This command displays both the details of the corresponding Volume Names and Paths
@echo on
call mountvol.exe
@echo off

@echo.
@echo.
pause

rem ***************
cls
@echo.
@echo.

rem This command displays the available "shares"
@echo on
net share
@echo off

@echo.
@echo.
pause


rem ***************
cls
@echo.
@echo.

rem This command stops sharing the available "shares"
@echo on
net share F /delete
net share G /delete
@echo off

@echo.
@echo.
pause

rem ***************
cls
@echo.
@echo.

rem This command shares out the USB directory drive with an assigned shared name
@echo on
net share F=F:
net share G=G:
@echo off

@echo.
@echo.
pause

rem ***************
cls
@echo.
@echo.

rem This command displays the available "shares"
@echo on
net share
@echo off

@echo.
@echo.


Discussion

No Comment Found