4

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.

ShizukaSM
  • 343
  • 2
  • 5
  • 15

5 Answers5

13

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"
Guido Preite
  • 14,905
  • 4
  • 36
  • 65
  • Actually, your answer was the only one that worked, since the other ones received an error in a folder with spaces (e.g. Doccuments and settings), thanks! Do you know if there's any way to add an "except"?(something like `for /r %%i in (*.exe) do start "" /b "%%i" except blabla.exe`) – ShizukaSM Mar 31 '13 at 00:41
  • 1
    try in this way `for /r %%i in (*.exe) do if not "%%~nxi" == "blabla.exe" start "" /b "%%i"` – Guido Preite Mar 31 '13 at 00:59
4

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

for %x in (*.exe) do ( start "" /b  "%x" )
Vassilis Barzokas
  • 3,105
  • 2
  • 26
  • 41
2

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.

Sheng
  • 3,467
  • 1
  • 17
  • 21
0

In a bat file add this line

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

This execute every .exe file in your current directory. same as

*.exe

would have done if * were supported on batch.

If you want to execute it directly from a command line window, just do

FOR /F "tokens=4" %G IN ('dir /A-D /-C ^| find ".exe"') DO start "" /b %G
Michael
  • 148
  • 7
0

Don't blame their codes for space issue. You should know how to use double quotation marks.

for /f "delims=" %%a in ('dir /b /s *.exe') do (
    start "" "%%a"
)
Batcher
  • 167
  • 1
  • I don't. And I still gave a +1 since it **half** worked. I just gave the best answer the selected one, I don't know why you are being so bitter about it. – ShizukaSM Mar 31 '13 at 14:19