How to execute any .exe by using a batch file?

automation, batch-file, exe, windows

Solution

if you plan to run inside a batch file you can do in this way:

for %%i in (*.exe) do start "" /b "%%i"

if you want to skip a particular file to be executed:

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

if is necessary to check also the subfolders add the /r parameter:

for /r %%i in (*.exe) do start "" /b "%%i"

Problem

I know that I can start an exe by doing: ``` start "" /b filename.exe ``` But that requires me to know the name of filename.exe, how could I do that for any general file ending with .exe? I tried the obvious wildcard implementation: ``` start "" /b *.exe ``` Windows, however, gives me an error saying it cannot find "*.exe" file.

Original source