General Question

XOIIO's avatar

Why won't this batch script work?

Asked by XOIIO (18328points) July 22nd, 2011

I have this batch script, I want it to loop the little animation while a program is running, but it only cycles once and then goes to the next part of the script. How can I get this to work in xp, vista and 7?

echo Windows Media Player 1/11
START wmp11-windowsxp-x86-enu.exe
echo.

:loop
echo INSTALLING WINDOWS MEDIA PLAYER…...........................................^|
ping localhost -n 1 >nul
cls
echo INSTALLING WINDOWS MEDIA PLAYER…...........................................^/
ping localhost -n 1 >nul
cls
echo INSTALLING WINDOWS MEDIA PLAYER…...........................................^-
ping localhost -n 1 >nul
cls
echo INSTALLING WINDOWS MEDIA PLAYER…...........................................^\
ping localhost -n 1 >nul
cls
tasklist|>nul find /i “wmp11-windowsxp-x86-enu.exe”
if errorlevel 1 (
GOTO next
) else (
GOTO loop
)

Observing members: 0 Composing members: 0

4 Answers

funkdaddy's avatar

outputting your variables before you check the loop would probably get you closer and let you know where the problem lies…

You may also want to reverse your checks… check for your loop condition and then check for your continuation… so loop always gets checked first.

robmandu's avatar

Just going by this bit:

tasklist|>nul find /i “wmp11-windowsxp-x86-enu.exe”
if errorlevel 1 ( GOTO next )

It would appear your command is kicking out a “1” into errorlevel.

Have you confirmed errorlevel is actually zero?

XOIIO's avatar

@robmandu No, but from other scripts I’ve seen it does set it to one if the program is running. Besides that, I remeber why I dont like errorlevels.

XOIIO's avatar

I tried using this with and without the else part, but it either runs once or doesnt at all. uhg

:loop
tasklist /nh /fi “imagename eq wmp11-windowsxp-x86-enu.exe” | find /i “wmp11-windowsxp-x86-enu.exe” >nul && (
GOTO next) ELSE (
echo INSTALLING WINDOWS MEDIA PLAYER…...........................................^|
ping localhost -n 1 >nul
cls
echo INSTALLING WINDOWS MEDIA PLAYER…...........................................^/
ping localhost -n 1 >nul
cls
echo INSTALLING WINDOWS MEDIA PLAYER…...........................................^-
ping localhost -n 1 >nul
cls
echo INSTALLING WINDOWS MEDIA PLAYER…...........................................^\
ping localhost -n 1 >nul
cls
GOTO loop
)

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther