0

So I am currently trying to make a script to run files out of a folder I specify. I expect that the outcome would run the files in the folder however when the program runs, it will display the code and not actually run it.

Here is the batch file I have outside of the folder:

for %%i in (C:\Desktop\ABC\A\*) do %%i 
Pause

Then inside of the folder named 'A' I have another batch file called 'This Will Run'

However, when I run the program I get this output :

C:\Users\Administrator\Desktop\ABC>for %i in (C:\Desktop\ABC\A\*bat) do %i

C:\Users\Administrator\Desktop\ABC>pause

Other than this nothing happens and the program closes when I press a button.

I found another question with the same question as I, however it was very out of date and currently does not work.

Link : Batch file execute all files in a folder

Thank you!

  • Does this answer your question? [How to run multiple .BAT files within a .BAT file](https://stackoverflow.com/questions/1103994/how-to-run-multiple-bat-files-within-a-bat-file) – The Fool Nov 13 '19 at 23:16
  • `for %%i in ("c:\Desktop\ABC\A\*.*") do "%%~i"` – Gerhard Nov 14 '19 at 06:18

1 Answers1

0

Change your code a bit like this:

@echo off
pushd C:\Desktop\ABC\A
for %%a in (*.bat) do start "" "%%~i"
popd
pause >nul
programmer365
  • 12,641
  • 3
  • 7
  • 28