!BAT
set /l instr=%1
set l_instr=%@retval%
set /l substr=%2
set l_substr=%@retval%
set site=0
:loop
call echo %^instr:~%site%,%l_substr%%% | set strtemp=
set /a site=%site%+1 > nul
if "%substr%"=="%strtemp%" exit
if "%site%"<=%l_instr% goto :loop
可以直接使用cat命令
set instr=abcdddddfffadsf
set str_len=%@retval%
set substr=cd
write (md)0x200+1 %instr%
cat --locatei=%substr% --number=1 (md)0x200+1,%str_len% | set site=