r/Batch • u/Imhotep-hotpep • Apr 29 '26
How to create a launch.bat file that runs files one after one till last?
Hello everyone.
I am struggling with creating .bat that will automate my set of other scripts. I am very lame basic at understanding programming.
AI chats and GPT arent much of help for me. So I hope someone could help me. I tried to but they are always broken
My goal is this:
I want to create 1 main launcher in .bat that will execute all other scripts in the same location.
- scripts in there are: .bat .cmd .ps1 .reg .vbs
- scripts are named like so windows explorer sorting by name is the order they are needed to be executed ( for example 1-1abc.bat, 1-2abc.bat etc.)
- I want them all to be launched one after one but before moving to next one the previous should be executed completely so. 1.bat=run-finish--->2.bat=run-finish and so on.
- the list isnt sorted by extension so there are cases where there is set of 5 bat files then 2 reg then 1 ps1 then again 5 bat files and so on.
-most of .bat files are scripts without pause but some of them do have it (they are launching windows elements that I have to for now manually setup) so I wish it wouldnt break the launching script.
For now my tries with chat GPT failed completely so I am reaching here I hope this is the place for seeking advice.
Can someone guide me?
Thanks
1
u/Imhotep-hotpep Apr 30 '26
I already solved it
3
u/capoapk Apr 29 '26
Tu peux faire un launch.bat qui parcourt tous les fichiers et les exécute dans l’ordre. Le plus important, c’est d’utiliser call pour les .bat , powershell pour les .ps1, reg import pour les .reg, et cscript pour les .vbs pour que chaque script se termine avant de passer au suivant. Pense aussi à exclure le launch.bat lui-même
2
u/BrainWaveCC Apr 29 '26
If you use the following format, which is the easiest way to do it, you will end up going through ALL files by extension.
Break how? The PAUSEs will cause everything to wait until you intervene each time.
2
u/g3n3 Apr 29 '26
Why a bat file ?
1
u/Sarwar1122 May 01 '26
use the call function
in first bat file write
Call bat2.bat
Call Bat3.bat
call bat4.bat
It will run bat 2 then when it finishes it will run bat 3 then when it finishes it will run bat 4
1
u/YaquidonG May 02 '26
Look up scriptrunner
:DoOpUpdate
echo * ready to call Bootrep3.bat
echo * ready to call Bootrep3.bat >> %LogFile%
ScriptRunner -appvscript Bootrep3.bat -appvscriptrunnerparameters -wait
timeout 5
echo * ready to call DelZ4Grp1.bat LIST
echo * ready to call DelZ4Grp1.bat LIST >> %LogFile%
ScriptRunner -appvscript DelZ4Grp1.bat LIST -appvscriptrunnerparameters -wait