Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 674
ShizukaSM Avatar asked Nov 30 '22 21:11

ShizukaSM


2 Answers

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

for %x in (*.exe) do ( start "" /b  "%x" )
like image 20
Vassilis Barzokas Avatar answered Dec 04 '22 07:12

Vassilis Barzokas


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"
like image 172
Guido Preite Avatar answered Dec 04 '22 05:12

Guido Preite