Kiera Smith
Kiera Smith

Reputation: 331

How to install all .exe in a folder using a batch file?

I am trying to develop the following algorithm:

For all files in the current folder (folder containing the script) do: install the files one by one

cls
setlocal disableDelayedExpansion

if %PROCESSOR_ARCHITECTURE%==x86 set arch=x86
if %PROCESSOR_ARCHITECTURE%==AMD64 set arch=x64

for /r "%~dp0" %%m in ("*.exe") do (
    set expath=%%m
    set exfile=%%~nm

    expath :: execute the .exe files
)
echo.
echo Done! 
echo.
pause
goto :eof

echo %exfile%

Upvotes: 0

Views: 4318

Answers (1)

Mofi
Mofi

Reputation: 49086

This little batch file starts each .exe file in directory of the batch file as separate process. Batch processing is halted after starting an executable until the started application terminated itself.

@echo off
setlocal DisableDelayedExpansion
for %%I in ("%~dp0*.exe") do (
    start "Running %%~nI" /wait "%%I"
)
endlocal

For the details on the used commands, open a command prompt window and run there the following command lines to get displayed the help for each command:

  • for /?
  • start /?

Upvotes: 2

Related Questions