Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Multiple commands for a batch file in a for loop?

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 17-02-2009
Member
 
Join Date: Aug 2008
Posts: 475
Multiple commands for a batch file in a for loop?
  

HI,

Multiple commands for a batch file in a for loop?

Is this possible to do?

Regards,

Reply With Quote
  #2  
Old 17-02-2009
Member
 
Join Date: May 2008
Posts: 44
Re: Multiple commands for a batch file in a for loop?

You need to code ONE command per line and checking errorlevel has to be coded as below, i.e.

for /f "options" %%a in (fileset.txt) do (
fc /b /c %source%\%%d
if errorlevel 1 call error.bat)

or use the conecting operator ||

for /f "options" %%a in (fileset.txt) do (
fc /b /c %source%\%%d || call error.bat)

Anyway your FC command lacks the second file to be compared.
Reply With Quote
  #3  
Old 17-02-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
Re: Multiple commands for a batch file in a for loop?

You could try using the ampserand...

FOR something DO command1 & command2 & command3

but I really don't like doing that in loops or IF statements. Instead, use parens.

For something DO (
command1
command2
command3
)
NOTE: the parens should be used in the exact syntax above - I'm fairly certain trying
FOR something Do (something & something & something)
won't work, nor will
IF something (something & something & something) ELSE (something & something & Something)
(Haven't tested either of the above, but paren use in batch files can be picky - they should always work if you do them the way I first demonstrated).
Reply With Quote
  #4  
Old 05-05-2012
Member
 
Join Date: Apr 2009
Posts: 567
Re: Multiple commands for a batch file in a for loop?

It can be done by creating different kind of bat file and then calling them one by one. I had seen certain script which workfine in that way. What you need to do is creat a multiple bat file like1.bat, 2.bat, 3.bat, etc. Then create a another script and call them one by one and loop if you want to run that file back again. In this way you can add multiple files inside a single script. This works fine, check properly that you are not missed any code.
Reply With Quote
  #5  
Old 08-05-2012
Member
 
Join Date: Jun 2011
Posts: 43
Re: Multiple commands for a batch file in a for loop?

I found a another way by which you can run multiple file from the run file. It is right that you need to bifurcate the script in different files. Then you can run that in the form task. For example schtasks /run /tun first task schtasks /run /tun second task, etc. Try this out and run them all once. I hope this script can help you to some extent. There are number of complications involved building up multi command loop script.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Multiple commands for a batch file in a for loop?"
Thread Thread Starter Forum Replies Last Post
Multiple commands in batch file loop Toshaan Vista Help 10 08-05-2012 11:39 AM
How to execute commands of batch file at timed intervals Camryn Software Development 5 27-03-2010 09:47 PM
Batch File Commands Pratap Gad Operating Systems 3 30-07-2009 09:07 PM
Batch Commands To Read and Delete Lines from txt-File officer07 Windows Server Help 3 04-03-2009 12:49 PM
How to create a script in a DOS batch file to do a loop? Jon Osborn Windows Server Help 2 27-05-2008 07:41 PM


All times are GMT +5.5. The time now is 12:12 AM.