Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: need a command that tests for a drive letter  (Read 5156 times)

0 Members and 1 Guest are viewing this topic.

sethcathison

    Topic Starter


    Newbie

    need a command that tests for a drive letter
    « on: February 05, 2009, 03:55:07 AM »
    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

    Seth

    mayers57



      Rookie

      Re: need a command that tests for a drive letter
      « Reply #1 on: February 05, 2009, 04:46:12 AM »
      Here 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
      Mike aka GEGeek

      sethcathison

        Topic Starter


        Newbie

        Re: need a command that tests for a drive letter
        « Reply #2 on: February 05, 2009, 05:03:41 AM »
        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.

        mayers57



          Rookie

          Re: need a command that tests for a drive letter
          « Reply #3 on: February 05, 2009, 05:08:20 AM »
          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. 
          Mike aka GEGeek

          mayers57



            Rookie

            Re: need a command that tests for a drive letter
            « Reply #4 on: February 05, 2009, 05:16:04 AM »
            I believe this is it.
            http://www.backupusb.com/
            Mike aka GEGeek

            Dias de verano

            • Guest
            Re: need a command that tests for a drive letter
            « Reply #5 on: February 05, 2009, 06:10:07 AM »
            Quote
            There maybe no files on the usb stick so i cannot  use the IF EXIST command

            IF exist will find the root folder.

            Biker Steve



              Rookie

              Re: need a command that tests for a drive letter
              « Reply #6 on: February 05, 2009, 08:13:43 AM »
              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.