|
| ||||||||||
| Tags: batch file, for loop, multiple commands |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Multiple commands for a batch file in a for loop?
Multiple commands for a batch file in a for loop? Is this possible to do? Regards, |
|
#2
| ||||
| ||||
| 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. |
|
#3
| ||||
| ||||
| 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). |
|
#4
| |||
| |||
| 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. |
|
#5
| |||
| |||
| 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. |
![]() |
|
| Thread Tools | Search this Thread |
| |
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 10:39 AM |
| How to execute commands of batch file at timed intervals | Camryn | Software Development | 5 | 27-03-2010 08:47 PM |
| Batch File Commands | Pratap Gad | Operating Systems | 3 | 30-07-2009 08:07 PM |
| Batch Commands To Read and Delete Lines from txt-File | officer07 | Windows Server Help | 3 | 04-03-2009 11:49 AM |
| How to create a script in a DOS batch file to do a loop? | Jon Osborn | Windows Server Help | 2 | 27-05-2008 06:41 PM |