Complete rewrite of NucleoFlasher.bat

Rewrote to use WMIC as the previous version didn't work on some machines, and also using WMIC is a much more elegant way to find the mass storage device (disk drive)
This commit is contained in:
Roger Clark 2016-10-02 13:58:48 +11:00 committed by GitHub
parent de95abde3f
commit bf2bb4cb76

View file

@ -1,16 +1,9 @@
@ECHO off
SET SOURCE=%2
SET SRC_PARSE=%SOURCE:/=\%
SET TARGET=%4
FOR %%I IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO (
VOL %%I: 2>NUL | FIND "%TARGET%" >NUL && SET DEST=%%I:
)
IF DEFINED DEST (
XCOPY %SRC_PARSE% %DEST% /Y /Q >NUL
) ELSE (
ECHO %TARGET% not found. Please ensure the device is correctly connected
EXIT /B 1
)
setlocal enabledelayedexpansion
for /F "skip=1 tokens=*" %%a in ('WMIC LOGICALDISK where "volumename like '%TARGET%%%'" get deviceid') do if not defined id set id=%%a
Call Set "deviceid=%%id: =%%"
if not "%deviceid%" == "" (XCOPY %SRC_PARSE% %deviceid% /Y /Q >NUL
echo Upload complete ) else ( echo %TARGET% not found. Please ensure the device is correctly connected)