Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How check a process?

14 views
Skip to first unread message

Jawade

unread,
May 25, 2008, 11:19:38 AM5/25/08
to
How to check if a process exist?

--
Met vriendelijke groeten, Jawade. BackUp-progje weer vernieuwd.
http://jawade.nl/ Met een mirror op http://jawade.fortunecity.com/
Bootmanager (+Vista +Linux), ClrMBR, DiskEdit (+Linux), POP3lezer,
DOS-Filebrowser, Kalender, Webtellers en IP-log, USB-stick tester.

Timo Salmi

unread,
May 25, 2008, 2:25:14 PM5/25/08
to
Jawade <Henk_...@hotmail.com> wrote:
> How to check if a process exist?

http://www.netikka.net/tsneti/info/tscmd068.htm

All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FI-65101, Finland
Timo's FAQ materials at http://www.uwasa.fi/~ts/http/tsfaq.html

Jawade

unread,
May 25, 2008, 3:40:27 PM5/25/08
to
In article <4839af0b$0$23816$9b53...@news.fv.fi>, Timo Salmi <t...@uwasa.fi> says...

> Jawade <Henk_...@hotmail.com> wrote:
> > How to check if a process exist?
>
> http://www.netikka.net/tsneti/info/tscmd068.htm
>
> All the best, Timo

I found no tasklist.exe at mij XP-Home pc, but I found it at a XP-
Pro pc. Now it works fine, thanks.

Another question: If there is a batch-process, the name is cmd.exe
but how can I check one specific batch-process?

Mike Walsh

unread,
May 25, 2008, 6:58:59 PM5/25/08
to

Jawade wrote:
>
> In article <4839af0b$0$23816$9b53...@news.fv.fi>, Timo Salmi <t...@uwasa.fi> says...
> > Jawade <Henk_...@hotmail.com> wrote:
> > > How to check if a process exist?
> >
> > http://www.netikka.net/tsneti/info/tscmd068.htm
> >
> > All the best, Timo
>
> I found no tasklist.exe at mij XP-Home pc, but I found it at a XP-
> Pro pc. Now it works fine, thanks.
>
> Another question: If there is a batch-process, the name is cmd.exe
> but how can I check one specific batch-process?

Use tasklist /v
The window title for each process will be displayed.

--
Mike Walsh

Ted Davis

unread,
May 25, 2008, 9:46:17 PM5/25/08
to
On Sun, 25 May 2008 21:40:27 +0200, Jawade wrote:

> Another question: If there is a batch-process, the name is cmd.exe but how
> can I check one specific batch-process?

In general, you can't do that easily: the only reasonable way would be to
look at the window title, but it may not stay set in batch files -
sometimes it becomes the name of the last .EXE to run.

--

T.E.D. (tda...@mst.edu) MST (Missouri University of Science and Technology)
used to be UMR (University of Missouri - Rolla).

Todd Vargo

unread,
May 25, 2008, 10:55:42 PM5/25/08
to

"Ted Davis" <tda...@umr.edu> wrote in message
news:pan.2008.05.26....@umr.edu...

> On Sun, 25 May 2008 21:40:27 +0200, Jawade wrote:
>
> > Another question: If there is a batch-process, the name is cmd.exe but
how
> > can I check one specific batch-process?
>
> In general, you can't do that easily: the only reasonable way would be to
> look at the window title, but it may not stay set in batch files -
> sometimes it becomes the name of the last .EXE to run.

Yes but it is possible to set a unique window title for the purpose of
locating the current window then the title can be reset afterwards.

set uniq=%random%
title %uniq%
tasklist /v|find "%uniq%"
title %0

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

Timo Salmi

unread,
May 25, 2008, 11:49:55 PM5/25/08
to
Jawade <> wrote:
> In article <4839af0b$0$23816$9b53...@news.fv.fi>, Timo Salmi <t...@uwasa.fi> says...
>> Jawade <Henk_...@hotmail.com> wrote:
>>> How to check if a process exist?
>> http://www.netikka.net/tsneti/info/tscmd068.htm

> Another question: If there is a batch-process, the name is cmd.exe


> but how can I check one specific batch-process?

Using the second of the tricks in that same item to distinguish between
the potential many cmd.exe processes running. That is usingthe ID-file
as in there or window title-id as suggested by Ted and Todd.

All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FI-65101, Finland

Useful CMD script tricks http://www.netikka.net/tsneti/info/tscmd.htm

Timo Salmi

unread,
May 26, 2008, 12:12:27 AM5/26/08
to
Ted Davis <tda...@umr.edu> wrote:
> On Sun, 25 May 2008 21:40:27 +0200, Jawade wrote:
>> Another question: If there is a batch-process, the name is cmd.exe but how
>> can I check one specific batch-process?

> In general, you can't do that easily: the only reasonable way would be to
> look at the window title, but it may not stay set in batch files -
> sometimes it becomes the name of the last .EXE to run.

Actually, it is not that difficult. E.g. if I happen to run dir /s c:\
in another cmd window the essential information displayed by tasklist /v
concerning that process is

... cmd.exe - dir /s c:\

which is easily tested for.

All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FI-65101, Finland

Jawade

unread,
May 26, 2008, 12:42:15 AM5/26/08
to
In article <eJp_j.2029$jI5...@flpi148.ffdc.sbc.com>, Todd Vargo <tlv...@sbcglobal.netz> says...

> "Ted Davis" <tda...@umr.edu> wrote in message
> news:pan.2008.05.26....@umr.edu...
> > On Sun, 25 May 2008 21:40:27 +0200, Jawade wrote:
> >
> > > Another question: If there is a batch-process, the name is cmd.exe but how
> > > can I check one specific batch-process?
> >
> > In general, you can't do that easily: the only reasonable way would be to
> > look at the window title, but it may not stay set in batch files -
> > sometimes it becomes the name of the last .EXE to run.
>
> Yes but it is possible to set a unique window title for the purpose of
> locating the current window then the title can be reset afterwards.
>
> set uniq=%random%
> title %uniq%
> tasklist /v|find "%uniq%"
> title %0

Wow, that's a miracle. Never too old to learn. All the problems
are solved. Thank you, ant thanks to all.

Timo Salmi

unread,
May 26, 2008, 12:03:30 PM5/26/08
to
It is quite possible that there are several cmd.exe windows open and a
script or program running in one of them. Since all are labeled cmd.exe
the question arises how to test if a particular script is being run.
This is how to solve the task:

@echo off & setlocal enableextensions
set myscriptIsRrunning_=
tasklist /v|findstr /b /i /r /c:"cmd.exe.*-.*myscript">nul
if %errorlevel% EQU 0 set myscriptIsRunning=true
if defined myscriptIsRunning (
echo myscript is currently running
) else (
echo myscript is not currently running)
endlocal & goto :EOF

Ted Davis

unread,
May 26, 2008, 1:28:27 PM5/26/08
to
On Mon, 26 May 2008 06:42:15 +0200, Jawade wrote:

> In article <eJp_j.2029$jI5...@flpi148.ffdc.sbc.com>, Todd Vargo
> <tlv...@sbcglobal.netz> says...
>> "Ted Davis" <tda...@umr.edu> wrote in message
>> news:pan.2008.05.26....@umr.edu...
>> > On Sun, 25 May 2008 21:40:27 +0200, Jawade wrote:
>> >
>> > > Another question: If there is a batch-process, the name is cmd.exe
>> > > but how can I check one specific batch-process?
>> >
>> > In general, you can't do that easily: the only reasonable way would be
>> > to look at the window title, but it may not stay set in batch files -
>> > sometimes it becomes the name of the last .EXE to run.
>>
>> Yes but it is possible to set a unique window title for the purpose of
>> locating the current window then the title can be reset afterwards.
>>
>> set uniq=%random%
>> title %uniq%
>> tasklist /v|find "%uniq%"
>> title %0
>
> Wow, that's a miracle. Never too old to learn. All the problems are
> solved. Thank you, ant thanks to all.

That's strange: all that tells you is that the batch file making
the test is running, but you already know that or it wouldn't be able to
make the test. It doesn't work in that form from other batch files. When
expanded to mark individual batch files, it sometimes fails because the
title has been changed to the name of an application the batch ran.

From the point of view of another batch file the example code reduces in
practice to

change window's title to something random

which is pretty much the state of affairs anyway.

This sort of code is useful for obtaining information about the batch file
that makes the test, but not for reliably obtaining information about
other batch files.

I have a batch file that changes parts or all of the window title many
thousands of times during its run.

Jawade

unread,
May 26, 2008, 2:07:14 PM5/26/08
to
In article <pan.2008.05.26....@umr.edu>, Ted Davis <tda...@umr.edu> says...

Well, it works fine. I use the batch for starting an emailchecker
and with a loop and sleep-timer it stays active. The meaning is
that the process not may start another time. If I try, it checks
if my title exists, and if so, it quittes. I have tested for
changing the title, but it don't. See here the first part from
the batch:

@echo off

tasklist /v|find "ePrompterTimer"
if %errorlevel% EQU 0 goto :end

title ePrompterTimer

:loop

...

Jawade

unread,
May 26, 2008, 2:49:24 PM5/26/08
to
In article <483adf53$0$23844$9b53...@news.fv.fi>, Timo Salmi <t...@uwasa.fi> says...

> It is quite possible that there are several cmd.exe windows open and a
> script or program running in one of them. Since all are labeled cmd.exe
> the question arises how to test if a particular script is being run.
> This is how to solve the task:
>
> @echo off & setlocal enableextensions
> set myscriptIsRrunning_=
> tasklist /v|findstr /b /i /r /c:"cmd.exe.*-.*myscript">nul
> if %errorlevel% EQU 0 set myscriptIsRunning=true
> if defined myscriptIsRunning (
> echo myscript is currently running
> ) else (
> echo myscript is not currently running)
> endlocal & goto :EOF
>
> All the best, Timo

Thank you, I have saved it. My batch works fine so I am glad. :-)

foxidrive

unread,
May 27, 2008, 6:41:45 AM5/27/08
to
On Mon, 26 May 2008 12:28:27 -0500, Ted Davis <tda...@umr.edu> wrote:

>I have a batch file that changes parts or all of the window title many
>thousands of times during its run.

What happens if you set a Window Title with the Title command, Ted?

** Posted from http://www.teranews.com **

0 new messages