Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Running batch file commands one at a time  (Read 2842 times)

0 Members and 1 Guest are viewing this topic.

jim_999

  • Guest
Running batch file commands one at a time
« on: January 29, 2008, 11:47:11 AM »
windows xp 2002:

I'm using a batch file to launch other programs. I'd like the batch processing to stop until each program has completed before executing the next command. For instance I will launch program Z which leaves several junk files in the folder when it's done. So, I would like the next command to delete the unwanted junk files. This isn't working now because the batch file launches program Z then immediately executes the delete command. Of course the junk files don't exist yet, so It's not doing what I need. 

WillyW



    Specialist
  • Thanked: 29
  • Experience: Experienced
  • OS: Windows XP
Re: Running batch file commands one at a time
« Reply #1 on: January 29, 2008, 12:12:02 PM »
Can you post the text of your batch file here?
.



jim_999

  • Guest
Re: Running batch file commands one at a time
« Reply #2 on: January 29, 2008, 01:33:07 PM »
When I run the batch file below, the programs X.exe, Y.exe, and Z.exe are all started in separate windows. The del commands are executed immediately with no junk files created yet. So there's nothing to delete.

What I want is (1) run X.exe and wait until it's done (2) delete junk files from X.exe (3) run Y.exe and wait until it's done (4) delete junk files from Y.exe....so on.

The batch file looks like this:

rem start batch file:
X.exe
del Z_junk.*
Y.exe
del Y_junk.*
Z.exe
del Z_junk.*
rem end of batch file

Dusty



    Egghead

  • I could if she would, but she won't so I don't.
  • Thanked: 75
  • Experience: Beginner
  • OS: Windows XP
Re: Running batch file commands one at a time
« Reply #3 on: January 29, 2008, 02:33:52 PM »
Welcome to the CH forums.

Try:

X.exe && del X_junk.*
Y.exe && del Y_junk.*
etc.......

See here for explanation of Conditional Execution.

Good luck
One good deed is worth more than a year of good intentions.

WillyW



    Specialist
  • Thanked: 29
  • Experience: Experienced
  • OS: Windows XP
Re: Running batch file commands one at a time
« Reply #4 on: January 29, 2008, 04:30:26 PM »
When I run the batch file below, the programs X.exe, Y.exe, and Z.exe are all started in separate windows.

I don't use XP,  so I can't say for sure if that is normal or not.   But I don't think it is.    At least not without the use of the      start    command,  and your text of your batch file says that you are not using it.

I don't know why you are getting separate windows.   Based on your batch file, I would say that you would not.


Quote
What I want is (1) run X.exe and wait until it's done (2) delete junk files from X.exe (3) run Y.exe and wait until it's done (4) delete junk files from Y.exe....so on.

Which is exactly what your batch file looks like.    That is,  it runs line-by-line, in order.




.