试试下面的代码
@echo off&setlocal enabledelayedexpansion
for /f "tokens=1 delims=:" %%a in ('"reg query "hkey_local_machine\system\currentcontrolset\enum\ide" /s|findstr /n "UserWriteCacheSetting""') do set /a num=%%a
set /a num=num-1
for /f "tokens=2 delims=:" %%i in ('"reg query "hkey_local_machine\system\currentcontrolset\enum\ide" /s|findstr/n .|findstr /b "%num%""') do set pa=%%i
echo !pa!