如何用bat搜索本机的文件并运行

来源:百度知道 编辑:UC知道 时间:2024/05/14 05:51:52
麻烦解释一下各行的意思 谢谢
是用bat搜索本机的一个指定文件并运行

@echo off
set "str=程序名.exe"
set "drv=c d e f g h i j k l m n o p q r s t"
for %%a in (%drv%) do (
if exist %%a: (
for /f "delims=" %%b in ('dir /s/b/a-d "%%a:\%str%" 2^>nul') do (
if not "%%b"=="" (
start "" "%%b"
exit
)
)
)
)
echo 找不到文件
pause

这样就可以了

@echo off---- 关闭显示
start 运行文件