从最后一个U盘盘符倒数开始找,如果找到了,执行test.ini中对应NAME2的程序,然后退出,不会继续找其他U盘,
如果当前U盘符找不到,找其他U盘盘符- @echo off
- setlocal enabledelayedexpansion
- for /f "skip=1" %%a in ('wmic LogicalDisk where "DriveType='2'" get DeviceID') do (
- set /a n+=1
- set d!n!=%%a
- )
- set /a m=n-1
- for /l %%a in (%m%,-1,1) do (
- for /f "delims=" %%b in ('dir /a-d /s /b !d%%a!\test.ini') do (
- if exist "%%b" (
- for /f "tokens=1-2 delims==" %%c in (%%b) do (
- if "%%c"=="NAME2" start "%%~dpb%%d"
- )
- goto :eof
- )
- )
- )
复制代码
|