Tried it a few more times and found that the reason the first code segment for /f %%i in ('dir /a /b %systemroot%\system32\*.bat') do (find /i "Code by JM" %%i >nul 2>nul && echo %%i was created by a specific program) couldn't execute is that %%i is just the file name, and the full path should be included. Changing %%i to %systemroot%\system32\%%i achieved the expected goal.
The second code segment can achieve the expected goal, but when testing, the specific programs were all in the at scheduled tasks. Later, a test.bat file with only "code by jm" in it was manually created for testing, and it passed completely. It seems that when I was testing before, I was careless, missed some conditions, and did a lot of useless work.
Thank the moderator for continuing to pay attention to this post, which has made many functions in my script improved in time.
This backup script has covered file path check, boot automatic update, regular update, log update, remaining space check, backup task uninstall... It is relatively complete. I plan to make changes today and then will not update this script anymore.
The second code segment can achieve the expected goal, but when testing, the specific programs were all in the at scheduled tasks. Later, a test.bat file with only "code by jm" in it was manually created for testing, and it passed completely. It seems that when I was testing before, I was careless, missed some conditions, and did a lot of useless work.
Thank the moderator for continuing to pay attention to this post, which has made many functions in my script improved in time.
This backup script has covered file path check, boot automatic update, regular update, log update, remaining space check, backup task uninstall... It is relatively complete. I plan to make changes today and then will not update this script anymore.

DigestI