Detect USB and copy *.* to USB drive using batch script

前端 未结 4 717
野性不改
野性不改 2020-12-15 14:13

I am trying to write a batch script to detect a USB drive and, if it is plugged in, for example copy c:\\test\\big.txt to the USB drive, and looping to detect anoth

4条回答
  •  醉酒成梦
    2020-12-15 14:28

    @Aacini I don't have a good setup to this case today, so I instead tried finding my USB webcam. I used devmgmt.msc and devcon listclasses to figure out the membership a connected USB camera would have. After a few tests, I arrived at devcon find =Image USB\*. I figured it would be simple enough to do the same for a USB mass storage device, so I tried devcon find =Volume (per listclasses). Unfortunately, this dumps out a GUID which you would then have to map to a drive letter. A cursory glance at this overflow suggests you can do so from the registry using reg query, but it seems at this point that fsutil would be simplest for your case.

提交回复
热议问题