locked
Get USB deviceid in variable RRS feed

  • Question

  • Hi,

    I have googled and tried out different solution without luck.

    I want to run a batch file that makes a dir on a USB drive but the problem is that the USB drive Changes driveid from time to time. Any solution?

    mkdir e:\%date%

    Robocopy C:\Program Files (x86)\Test E:\%date%

    The problem is that it isnt Always e:

    Thanks in advance.

    Thursday, July 21, 2016 8:48 PM

Answers

  • Im not creating a folder in program files i am backing up from program files to USB. I also thought that it would be the same slot until i was starting testing the batch. The USB hade changed from E to G without no other USB memory pluged in the computer.

    How can a create a directory with my label on the USB memory then? I

    • Marked as answer by Ollza Friday, July 22, 2016 6:20 AM
    Friday, July 22, 2016 6:10 AM

All replies

  • WHy would you create a folder in Program files.  This is not be used for user fie storage.

    If the drive letter is available the USB will always mount to the same letter after the first time.

    If you are adding new drives then there is no way to know which letter will be given.  YOU need to know the label on the drive or what the drives were before the USB was plugged in. 

    You can also use WMI to call a program when a new drive is mounted.


    \_(ツ)_/

    Thursday, July 21, 2016 9:08 PM
  • Im not creating a folder in program files i am backing up from program files to USB. I also thought that it would be the same slot until i was starting testing the batch. The USB hade changed from E to G without no other USB memory pluged in the computer.

    How can a create a directory with my label on the USB memory then? I

    • Marked as answer by Ollza Friday, July 22, 2016 6:20 AM
    Friday, July 22, 2016 6:10 AM