Tasklist command is not recognised when used in a function.

December 26, 2011 at 22:33:24
Specs: Windows XP
In my Windows XP machine i am trying to find if a process is running or not , using a batch file with the help of tasklist command .However the command returns the error 'Tasklist' is not a recognised internal or external command.When i use the command outside the function in the same batch file then it works properly.


See More: Tasklist command is not recognised when used in a function.

Report •


#1
December 27, 2011 at 10:25:00
Why can't you just open task manager up directly?

Right click the clock on the bottom right and select Task Manager.


Report •

#2
December 27, 2011 at 12:02:46
Can you post the code that you're using which returns the error?

Report •

#3
December 27, 2011 at 19:55:54
The code i use gets user input regarding the location of the applications binary in the functions 1,2,3 and then goes to the appwatch function wherein the execution freezes in the first tasklist command .It doesn't go past it.

:function1
if(
call :function2
)else(
goto :exit
)
:function2
if(
call :function3
)else(
goto :exit
)
:function3
if(
call :appwatch
)else(
goto :exit
)
:appwatch
TASKLIST /FI "IMAGENAME EQ myapp.exe" 2>NUL | FIND /I "myapp.exe" >> %DEBUGFILE% 2>&1
IF "%ERRORLEVEL%" == "0" (

ECHO myapp RUN
goto :appwatch

) ELSE (

ECHO myapp NOT RUN
goto :app restart

)


Report •

Related Solutions

#4
December 27, 2011 at 19:58:22
@gestohlenseele : Comeon man if i were to use task manager why would even bother about the batch script.? I want to automate the restart of an application if it closes which is why i have to use batch to find the status of the program.

Report •


Ask Question