How to execute any .exe using a batch file?

I know that I can run exe by doing:

start "" /b filename.exe 

But this requires finding the name filename.exe, how can I do this for any shared file ending in .exe? I tried the obvious implementation of wildcards:

 start "" /b *.exe 

Windows, however, gives me an error saying that it cannot find the "* .exe" file.

+4
source share
5 answers

if you plan to run inside a batch file, you can do it like this:

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

if you want to skip a specific file to execute:

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

if you need to check also that the subfolders add the / r option:

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

From cmd, run this in a folder in which there are all exe that you want to run:

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

Hep helps

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

You must first use the dir command to search for all exe files, and then execute it.

+2
source

In the bat file add this line

 FOR /F "tokens=4" %%G IN ('dir /AD /-C ^| find ".exe"') DO start "" /b %%G 

Executes each .exe file in your current directory. as well as

 *.exe 

would do if * was supported in batch mode.

If you want to execute it directly from the command prompt window, just do

 FOR /F "tokens=4" %G IN ('dir /AD /-C ^| find ".exe"') DO start "" /b %G 
0
source

Do not blame their codes for a space. You need to know how to use double quotes.

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

All Articles