| 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 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. |
|