Re quan_zhou:
If you call b.bat just to set file=%a%, you can directly write it in autoexec.bat, unless your %a% is not referencing an environment variable but is used as a variable indication. Further confusion is why not directly set the value to %file% in check.bat or directly use %a% for comparison in autoexec (compfile c:\1.txt %a%)? This can omit many intermediate twists.
As for fetching the content of a text file into a variable, this is a topic that has been discussed many times before. It depends on the complexity of your s.txt and your requirements for the position of the target to be obtained. If s.txt contains only one word and that's exactly what you want to get, you can use the date or time command to get it; if your s.txt is complex and changeable, you can use third-party tools such as LMOD or gawk, etc., and strings can also be considered. Their advantage is that they are easy to use and can handle various complex needs; if you cannot or are unwilling to use third-party tools, you can refer to the batch processing programs about text traversal (file traversal) that I posted before.
As for the second replacement problem you mentioned, in fact, it is a similar problem to the first one, and you can also try using LMOD/GAWK or the batch processing I mentioned. For their usage and related explanation descriptions, there are many in the past posts, and you can search and see.
※ Batchinger 致 Bat Fans:请访问
批处理编程的异类 ,欢迎交流与共享批处理编程心得!