Go Back   TechArena Community > Technical Support > Computer Help > Windows Vista > Vista Help
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Multiple commands in batch file loop

Vista Help


Reply
 
Thread Tools Search this Thread
  #1  
Old 13-03-2008
Member
 
Join Date: Nov 2005
Posts: 38
Multiple commands in batch file loop

I am running windows Vista enterprises. I have a small question hope you guys can help me out with this. I just wanted to know is it possible to execute more than one command in a batch file for each iteration of a FOR loop? I mean i want to run multiple commands for each file of the set. Is there anyway doing the same ?

Thanks for your helps.

Reply With Quote
  #2  
Old 14-03-2008
Member
 
Join Date: Sep 2004
Posts: 57
Re: Multiple commands in batch file loop

Yes, it is possible. In order to do the same you can create a secondary batch file that processes each file and call it like this:

for %f in (*.txt) do call process.bat %f

=process.bat=
@Echo Off
Command1.exe %1
Command2.exe %1
etc...

Let me know if you need anymore help with this.
Reply With Quote
  #3  
Old 14-03-2008
Member
 
Join Date: Jul 2004
Posts: 146
Re: Multiple commands in batch file loop

That is correct to some extent Casher but better than that you should also include the PowerShell equivalent like this :

Quote:
gci *.txt | % {Command1.exe $_.FullName; Command2.exe $_.FullName}
Reply With Quote
  #4  
Old 14-03-2008
Member
 
Join Date: Sep 2004
Posts: 119
Re: Multiple commands in batch file loop

I dont think you actually need to use a separate batchfile. Instead you can do that in the same batch by using ( and ) like this:

Quote:
For %%f in (*.txt) do (
Command1 %1
Command2 %1
)
Reply With Quote
  #5  
Old 18-02-2009
Member
 
Join Date: Feb 2009
Posts: 33
Re: Multiple commands in batch file loop

Hey even I was trying to find an answer for the same problem with commands in loop! Here i found some help with the batch files for loop!

I hope this helps you guys too!
Reply With Quote
  #6  
Old 25-09-2010
Member
 
Join Date: Sep 2010
Posts: 1
Re: Multiple commands in batch file loop

i need to test or avability of keyboard & mouse through batch file. Pl help
Reply With Quote
  #7  
Old 25-09-2010
Member
 
Join Date: Nov 2009
Posts: 359
Re: Multiple commands in batch file loop

Why do you need to write a batch script to test your keyboard and mouse. It is really simple by interrogating the system you can esaily detect if your keyboard and mouse are enabled or disabled.

Alternative you can use the PassMark KeyboardTest -
It is a tool for advanced configuration for your keyboard. You may like to check that your keyboard keys and the LEDs (Num Lock, for example) work correctly. In addition, the application analyzes your typing and how you show your typing speed and sensitivity recommended depending on your habits.
Reply With Quote
  #8  
Old 18-11-2010
Member
 
Join Date: Nov 2010
Posts: 2
Re: Multiple commands in batch file loop

hi guys i also have a problem. im trying to get my batch file to start over once it has finished.

my batch files looks like the following...

netsh wlan connect SKY03175 SKY03175
ping 127.0.0.1 -n10 -w 1000
ftp uploads.google.com
:top
GOTO top

now the batch file itself works fine. but the goto command only executes once i type in bye. and then all i get is a continouos list appearing like so

c:\GOTO top
c:\GOTO top
c:\GOTO top
c:\GOTO top

this doesnt stop until i manually stop it.
so basically the loop is failing to work in the way i want it to. help will be much appreciated :)
Reply With Quote
  #9  
Old 26-04-2011
Member
 
Join Date: Apr 2011
Posts: 1
Re: Multiple commands in batch file loop

mkay i registered on the forum just to help you out, try something like this
:top
netsh wlan connect SKY03175 SKY03175
ping 127.0.0.1 -n10 -w 1000
ftp uploads.google.com
choice /c:yn /m "run again?"
if errorlevel 2 goto top
Reply With Quote
  #10  
Old 05-05-2012
Member
 
Join Date: Aug 2011
Posts: 539
Re: Multiple commands in batch file loop

I prefer to go with a Batch File Maker. There are certain tools that can help you to generate a automated script for a process. You can edit that script and find the right command. Tool called as Batch File Maker is much easier to create batch files and modify them as per your need. The command line tool offer you to generate files with .bat exenstion and you can simply run them via cmd or run box. As the location for them is set to system32 folder inside Windows.
Reply With Quote
  #11  
Old 08-05-2012
Member
 
Join Date: Aug 2011
Posts: 394
Re: Multiple commands in batch file loop

I remember a tool called as ZIP Batch File Maker. I had used this tool on Vista and it worked simply well. What I do not find is many customization option tha we need. There are certain sample script on the web that you can download and use. Somehow the most irritating stuff is when you get that error in a ongoing process. Still there is not proper application that can help to generate a good batch file.
Reply With Quote
Reply

  TechArena Community > Technical Support > Computer Help > Windows Vista > Vista Help
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Multiple commands in batch file loop"
Thread Thread Starter Forum Replies Last Post
Multiple commands for a batch file in a for loop? SANDESH49 Software Development 4 08-05-2012 11:40 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 04:12 AM.