如何使用批处理文件执行任何.exe?

Shi*_*aSM 4 windows automation exe batch-file

我知道我可以通过以下方式启动exe:

start "" /b filename.exe
Run Code Online (Sandbox Code Playgroud)

但这需要我知道filename.exe的名称,我怎么能为任何以.exe结尾的常规文件做到这一点?我尝试了明显的通配符实现:

start "" /b *.exe
Run Code Online (Sandbox Code Playgroud)

但是,Windows给出了一个错误,说它无法找到"*.exe"文件.

Gui*_*ite 13

如果您打算在批处理文件中运行,可以这样做:

for %%i in (*.exe) do start "" /b "%%i"
Run Code Online (Sandbox Code Playgroud)

如果要跳过要执行的特定文件:

for %%i in (*.exe) do if not "%%~nxi" == "blabla.exe" start "" /b "%%i"
Run Code Online (Sandbox Code Playgroud)

如果有必要检查子文件夹添加/ r参数:

for /r %%i in (*.exe) do start "" /b "%%i"
Run Code Online (Sandbox Code Playgroud)