I am trying to make a simple batch file that finds an exe file in a folder and does a silent install of it. So far I have been unsuccessful with this:
for /r "%CD%\folder1\folder2\" %%a in (*.exe /sPB) do start "" "%%~fa"
Of course this gives me the error:
Windows cannot find 'E:\folder1\folder2\sPB'. Make sure you typed the name correctly, and then try again.
I know that the general command for the silent install would be something like:
mysoftware.exe /sPB
So where should I place the "silent install flags"? I realize that I should not put it after *.exe
.
Based on the fact you should know the location of your installer without the need to do a recursive search under folder1\folder2
, I'd suggest:
@Echo Off
CD /D "folder1\folder2" 2>Nul || Exit /B
For %%A In (AcroRdr*.exe) Do Start "" "%%A" /sPB /rs /msi
Although the method of installation should be the same either way:
For /R "folder1\folder2" %%A In (*.exe) Do Start "" "%%A" /sPB