@@ -457,7 +457,7 @@ func flashUF2UsingMSD(volume, tmppath string) error {
457
457
case "darwin" :
458
458
infoPath = "/Volumes/" + volume + "/INFO_UF2.TXT"
459
459
case "windows" :
460
- path , err := windowsFindUSBDrive ()
460
+ path , err := windowsFindUSBDrive (volume )
461
461
if err != nil {
462
462
return err
463
463
}
@@ -484,7 +484,7 @@ func flashHexUsingMSD(volume, tmppath string) error {
484
484
case "darwin" :
485
485
destPath = "/Volumes/" + volume
486
486
case "windows" :
487
- path , err := windowsFindUSBDrive ()
487
+ path , err := windowsFindUSBDrive (volume )
488
488
if err != nil {
489
489
return err
490
490
}
@@ -502,10 +502,10 @@ func flashHexUsingMSD(volume, tmppath string) error {
502
502
return moveFile (tmppath , d [0 ]+ "/flash.hex" )
503
503
}
504
504
505
- func windowsFindUSBDrive () (string , error ) {
506
- cmd := exec .Command ("wmic" , "PATH" , "Win32_LogicalDisk" ,
507
- "get " , "DeviceID," , "VolumeName, " ,
508
- "FileSystem, " , "DriveType" )
505
+ func windowsFindUSBDrive (volume string ) (string , error ) {
506
+ cmd := exec .Command ("wmic" ,
507
+ "PATH " , "Win32_LogicalDisk" , "WHERE" , "VolumeName = '" + volume + "' " ,
508
+ "get " , "DeviceID,VolumeName,FileSystem, DriveType" )
509
509
510
510
var out bytes.Buffer
511
511
cmd .Stdout = & out
@@ -559,8 +559,8 @@ func getDefaultPort() (port string, err error) {
559
559
case "linux" :
560
560
portPath = "/dev/ttyACM*"
561
561
case "windows" :
562
- cmd := exec .Command ("wmic" , "PATH" , "Win32_SerialPort" ,
563
- "get " , "DeviceID" )
562
+ cmd := exec .Command ("wmic" ,
563
+ "PATH" , "Win32_SerialPort" , "WHERE" , "Caption LIKE 'USB Serial%'" , "GET " , "DeviceID" )
564
564
565
565
var out bytes.Buffer
566
566
cmd .Stdout = & out
0 commit comments