Ashley Kirot
asked on
Create A Batch Script To Run All Batch Scripts In Current And Sub Directory's
I've been trying to, create a batch script to run all batch scripts in the current and sub directory's. So far the current script only runs one batch in the current directory.
My apologies for any trouble, thanks in advance.
@echo off
cd /d %~dp0
for /R %%s in (*.cmd) do (
call "%%~s")
PAUSE
My apologies for any trouble, thanks in advance.
ASKER
Thanks for the response, i ran the code, again. Still received the same results. Any ideas what I'm doing wrong?
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks, it found the scripts in the current and sub directory's.
How do I run the found scripts?
How do I run the found scripts?
Please post one or more of the called BAT scripts, it's possible they are not returning back to the calling BAT script.
Also, be sure that the original script can not call itself otherwise that will lead to an infinite loop. You may have to exclude that with an IF in the main script and make sure it doesn't try and execute itself.
»bp
Also, be sure that the original script can not call itself otherwise that will lead to an infinite loop. You may have to exclude that with an IF in the main script and make sure it doesn't try and execute itself.
»bp
ASKER
There being echoed, just not executing.
The master batch script,
call "C:\978978978\Run.cmd"
call "C:\978978978\Script_1.cmd"
call "C:\978978978\Execute\Script_2.cmd"
call "C:\978978978\Execute\Execute\Script_3.cmd"
The master batch script,
@echo off
cd /d %~dp0
for /R %%s in (*.cmd) do (
ECHO call "%%~s")
PAUSE
Correct, NVIT had you change it to just display the CALL statements, but not execute them. If they look right then change:
ECHO call "%%~s")
to:
call "%%~s")
»bp
ECHO call "%%~s")
to:
call "%%~s")
»bp
What is the "master script" file name?
»bp
»bp
ASKER
"Run.cmd", is the master script.
I tried changing it back to, call "%%~s")
Same result.
I tried changing it back to, call "%%~s")
Same result.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Many thanks! That helped, it's not executing itself anymore, & It can recurse the sub directory and execute.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Open in new window