Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch File to execute all .exe in a folder

I need to create a batch script that will run all .exe files in a folder. This must include subfolders.

I am running windows 7, and the batch file is stored in the root folder

I have tried several variations with no success. The two main variations are as follows

REM dir *.exe /S /B > tmpFile
REM set /p listVar= < tmpFile
REM del tmpFile

FOR %%F IN (%listVar%) DO %%F

=======================================

FOR /F "usebackq" %%F IN ('dir *.exe /S /B') DO %%F

I have looked through several variations on the above methods but none work. The top version (which I would like to avoid) only reads in one line from the file. The Bottom version outputs an unmodified "dir" command in the prompt window.

Ultimately I would like help identifying how to solve this issue without the need for a temp file.

like image 885
Luke Turner Avatar asked Feb 12 '23 21:02

Luke Turner


1 Answers

for /r "." %%a in (*.exe) do start "" "%%~fa"

This will start all the executable files under the current folder and subfolders. Change the reference to the current folder (".") to your needs.

like image 199
MC ND Avatar answered Feb 16 '23 02:02

MC ND