Batch scripts queueing loop script

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

Re: Batch scripts queueing loop script

#16 Post by foxidrive » 27 Feb 2013 15:07

You have a syntax error to begin with.

KgOlve
Posts: 14
Joined: 30 Oct 2012 06:34

Re: Batch scripts queueing loop script

#17 Post by KgOlve » 27 Feb 2013 15:13

foxidrive wrote:You have a syntax error to begin with.


It was the do() inside a do() command which i put it, wasn't it?

Queue
Posts: 31
Joined: 16 Feb 2013 14:31

Re: Batch scripts queueing loop script

#18 Post by Queue » 27 Feb 2013 15:19

Yes, but it is simply that an IF statement doesn't use DO, DO is part of a FOR statement. DO on its own isn't anything.

foxidrive, what's the purpose of using two find's? Wouldn't [find /c /i "process.exe"] work? I didn't change that in my posts because I assumed you had a reason.

Queue

foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

Re: Batch scripts queueing loop script

#19 Post by foxidrive » 27 Feb 2013 15:24

Queue wrote:foxidrive, what's the purpose of using two find's? Wouldn't [find /c /i "process.exe"] work? I didn't change that in my posts because I assumed you had a reason.

Queue


You are right - it does work fine that way. Two finds aren't necessary.

KgOlve
Posts: 14
Joined: 30 Oct 2012 06:34

Re: Batch scripts queueing loop script

#20 Post by KgOlve » 27 Feb 2013 15:28

This is the final code i ended up with. I just tried it both with none of the processes already running, and by running the batch script 3 times, making the 3rd one queue itself like it was supposed to. It's working wonderfully. Thanks for all the help.

Code: Select all

:queue
for /f %%a in ('tasklist ^|find /i "process.exe" ^|find /c /v "" ') do (
if %%a GEQ 2 (
timeout 60
goto:queue
)
)


Since you're talking about only 1 find being enough, is this how i should write it then?:

Code: Select all

:queue
for /f %%a in ('tasklist ^|find /c /i "process.exe" ^|"" ') do (
if %%a GEQ 2 (
timeout 60
goto:queue
)
)

Queue
Posts: 31
Joined: 16 Feb 2013 14:31

Re: Batch scripts queueing loop script

#21 Post by Queue » 27 Feb 2013 15:40

Code: Select all

:queue
for /f %%a in ('tasklist ^|find /c /i "process.exe"') do (
if %%a GEQ 2 (
timeout 60
goto:queue
)
)
Queue

KgOlve
Posts: 14
Joined: 30 Oct 2012 06:34

Re: Batch scripts queueing loop script

#22 Post by KgOlve » 27 Feb 2013 16:20

This one works too, thank you very much for all the help.
Problem solved then, i guess :)

Post Reply