Solved

Run multiple Batch files

Posted on 2008-06-19
7
376 Views
Last Modified: 2010-04-16
I have over 1000.Bat files that i have to run, What is the best way to do this, if anyone has a script or a link or can explain it to me , that would beg great.

thanks

exp.

run Bat1, bat2, bat3, bat4, out of folder /BatchFiles than delete batch files.
0
Comment
Question by:Jiggens
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 38

Expert Comment

by:Shift-3
ID: 21824789
Paste the script below into a text file with a .cmd extension.  Customize the value of the "folder" variable with the location of the BatchFiles folder.

Running the script will echo commands to run and delete every .bat file in that folder.  Once you have tested it successfully, remove the "echo" from lines 7 and 8.


@echo off
setlocal
 
set folder=C:\BatchFiles
 
for /F "tokens=*" %%G in ('dir "%folder%\*.bat" /B') do (
 echo call "%folder%\%%G"
 echo del "%folder%\%%G"
)
 
pause

Open in new window

0
 
LVL 1

Author Comment

by:Jiggens
ID: 21825321
i tested but they are not executing the echo call and echo del is showing for each file so its finding the folder and the file just not running?
0
 
LVL 1

Author Comment

by:Jiggens
ID: 21825362
The original batch files look like this


REM Activant
REM A fax failed to be sent out. This file has been created 
REM to resend the fax. Double click this file to resend the fax. 
REM 
vfx -H KMC.electricalsalesinc.local -B \\Sqlserver\jfsrvr\data\OR151704.rcp
REM Check to see if an error has occurred before continuing. 
pause 

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:Jiggens
ID: 21825400
I think i know why it wont run its because of the pause, its not going to execute in the existing batch file
0
 
LVL 38

Accepted Solution

by:
Shift-3 earned 500 total points
ID: 21825843
Try this to bypass the pauses.


@echo off
setlocal
 
set folder=C:\BatchFiles
 
for /F "tokens=*" %%G in ('dir "%folder%\*.bat" /B') do (
 echo. | "%folder%\%%G"
 echo del "%folder%\%%G"
)
 
pause

Open in new window

0
 
LVL 1

Author Comment

by:Jiggens
ID: 21825960
Yeah i am getting a message was unexpected at this time.

What does that mean?
0
 
LVL 38

Expert Comment

by:Shift-3
ID: 21827675
I dunno.  You'll have to review the batch script that returned the error.

Personally I don't much fancy troubleshooting a thousand of the things.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question