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

16,948

Solution 1

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"

Solution 2

From cmd run this to the folder that has all the exe you wish to run:

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

Solution 3

Hoep it helps

for /f "delims=" %%a in ('dir /b /s "*.exe"') do (
    start %%a
)

You should first use dir command to find all exe files, and then execute it.

Share:
16,948
ShizukaSM
Author by

ShizukaSM

Updated on June 04, 2022

Comments

  • ShizukaSM
    ShizukaSM almost 2 years

    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.