VMware Cloud Community
CDB1
Contributor
Contributor

Auto Connect USB Drive to Win10 VM on ESXi 8

I'm sure this has been covered, but I didn't find what I was looking for with the search function.

I have a test Win10Pro running on ESXi 8, with the intention of running backups with it. For Testing I have 2 identical USB Drives I would like to swap to simulate taking a backup off site. They are being plugged into the same USB port (on the front of the ESXi host). Currently they automatically show up in DiskManagement when swapped, but they are not assigned a drive letter and are unusable until I open Disk Management and assign them a drive letter, in this case F. Is there a way to accomplish this automatically?

Thanks.

Reply
0 Kudos
2 Replies
sdtslmn
Contributor
Contributor

there can be alternative solutions worth trying 

first use the USB passthrough feature https://www.nakivo.com/blog/how-to-use-usb-devices-with-a-vmware-vsphere-virtual-machine/

then on Windows create the following scripts 

 

select volume X
assign letter=F
exit

 


Replace X with the volume number of your USB drive. You can find this number by opening the Disk Management tool, right-clicking the USB drive, and selecting 'Properties'. Under the 'Volumes' tab, you should see the volume number.

Save this file with a .txt extension, e.g., assignletter.txt.

Create a batch script to run the DiskPart script:

 

diskpart /s assignletter.txt

 

 

Set up the batch script to run automatically:

This can be done using the Task Scheduler in Windows. Create a new task that triggers when an event from the 'DriverFrameworks-UserMode' with an ID of 2003 occurs. This event is logged each time a USB device is inserted.

 

 

Set the action of this task to start a program, and point it to your assignletter.bat file. Make sure that the user account running this task has the necessary permissions to run DiskPart commands.

Reply
0 Kudos
CDB1
Contributor
Contributor

Cool, Thank you very much. Since I have 2 (or MORE) drives to be rotated should I assume that each one will have a unique volume letter?

Perhaps a series of "select volume X", or "select volume Y" ... maybe a conditional based on volume number if that can be returned as an argument?

Thanks, again!

Reply
0 Kudos