Type: select disk n (where n is the number of your USB drive). IWbemServices::ExecMethod ("\\PC-NAME\ROOT\CIMV2:Win32_Volume. In the first place, connect your USB drive to your computer and make sure it can be detected. Here's what I'm doing in code (C ): /* Parameters are set as follows */ Running my code "As administrator" makes no difference.Ĭan anyone help me figure out what the Disk Management widget is doing differently, or what I'm missing? I'm at a loss as to why it doesn't work when it doesn't work, so I really don't know what to try next for a solution. Part 1 - format usb drive fat32 quick with diskpart Open cmd and type diskpart in the Run Type list disk Type list volume Type select volume Type format fs. Always the Disk Management widget can format it fine. Afterwords sometimes the drive will be in the funny state where I cannot format it, and sometimes I can format it fine. To put it into the funny state, I first copy data to the drive, then remove and recreate the partition using diskpart. I can reproduce this with multiple brands and sizes of USB flash drive. My code will even format it fine after removing the partition using diskpart and re-creating the partition, assuming it was formatted with the Disk Management widget prior to removing the partition. And after formatting with the Disk Management widget, my WMI code will also format it fine from that point forward. If you want to format the drive D:, then type: vol D: 2. Be very careful when selecting the hard drive to format. If the flash drive (usb fob) has a partition but no file system, and it's in the funny state, my WMI format code fails with error 11 "no media in drive", but using the Windows Disk Management widget the drive formats just fine. Where ' X ' the drive letter of the disk that you want to format. I've inherited some c code for formatting USB flash drives, but it fails if the flash disk is in a bad state and I can't figure out why (or what makes the flash disk state bad).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |