I know, that I can set the title of my window with the title command,
but is there a way in a batch, to find out my aktual window title?
regards
Arno
Why do you need to? You can set it and then you know what it is.
If you explain why the title is unknown then maybe someone can offer a
suggestion.
--
Regards,
Mic
to control batch Windows, I want to store their PID in some file.
To get the PID I modify the title to an unique one and filter it
through the tasklist command.
To repair the title I want to set it back after I have made it unique,
therfore I want to read it, before I set it. Mostly it will be
'cmd.exe'
but I prefer to do it in a more generic way.
Perhaps you have an other easy way, getting my own PID without
external or third party tools, than I can leave the title untouched,
but at least I also want to know if this is possible.
regards
Arno
but this doesn't help, if someone has started the batch over the start
command with his own title, or does it?
regards
Arno
c:$$> type f2.bat
@title mytitle2
@echo test1
pause
c:$$> start "" f1.bat
c:$$> start "" f2.bat
c:$$> tasklist /fi "imagename eq cmd.exe" /fo list /v
Nom de l'image: cmd.exe
PID : 164
Nom de la session: Console
Numéro de session: 0
Utilisation mémoire: 92 Ko
État : En service
Nom d'utilisateur : WALID2MI\Administrateur
Temps processeur: 0:00:00
Titre de la fenêtre : Administrateur
Nom de l'image: cmd.exe
PID : 1856
Nom de la session: Console
Numéro de session: 0
Utilisation mémoire: 1 448 Ko
État : En service
Nom d'utilisateur : WALID2MI\walid
Temps processeur: 0:00:00
Titre de la fenêtre : mytitle1 <--
Nom de l'image: cmd.exe
PID : 596
Nom de la session: Console
Numéro de session: 0
Utilisation mémoire: 1 448 Ko
État : En service
Nom d'utilisateur : WALID2MI\walid
Temps processeur: 0:00:00
Titre de la fenêtre : mytitle2 <---
> to control batch Windows, I want to store their PID in some file.
> To get the PID I modify the title to an unique one and filter it
> through the tasklist command.
That's the only way to get the PID with tasklist if there are several
CMD windows open at the time.
> To repair the title I want to set it back after I have made it unique,
> therfore I want to read it, before I set it. Mostly it will be
> 'cmd.exe'
> but I prefer to do it in a more generic way.
>
> Perhaps you have an other easy way, getting my own PID without
> external or third party tools, than I can leave the title untouched,
> but at least I also want to know if this is possible.
handle.exe from PStools will show the CMD.EXE and the PID and also the
current folder
You can change to a specific (temp?) folder, test for it and get the pid
from that instance of cmd.exe
c:\WINDOWS\Util\Pstools>handle -p cmd.exe
Handle v3.42
Copyright (C) 1997-2008 Mark Russinovich
Sysinternals - www.sysinternals.com
------------------------------------------------------------------------------
cmd.exe pid: 4932 MM\MM
C: File (RW-) C:\WINDOWS\Util\Pstools
6C: File (RW-)
C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_659
5b64144ccf1df_6.0.2600.6028_x-ww_61e65202
------------------------------------------------------------------------------
cmd.exe pid: 2640 MM\MM
C: File (RW-) C:\Documents and Settings
6C: File (RW-)
C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_659
5b64144ccf1df_6.0.2600.6028_x-ww_61e65202
--
Regards,
Mic
Arno doesn't know what the title is, and doesn't want to change it
unnecessarily, but wants the PID of the current batch file.
--
Regards,
Mic
thanks for your hints. Now I know what I will do.
First I capture a list with all processes, where the
image name is 'cmd.exe' (I hope this is language
independend),
second I calculate my PID, like I have done it before
and last I pick the title from the initial list with my
calculated PID and reset it.
many thanks for the discussion,
best regards
Arno