melmacker
Goto Top

Wie findet man heraus wie viele CMD Fenster offen sind?

Hallo erstmal,
ich habe eine Frage bezüglich eines Batch Befehls und zwar wollte ich wissen wie man herausfindet wie viele CMD Fenster offen sind.

Bedanke mich im voraus für jede Antwort.

Mit freundlichen Grüßen

Melmacker

Content-Key: 388794

Url: https://administrator.de/contentid/388794

Printed on: April 25, 2024 at 07:04 o'clock

Mitglied: 137289
137289 Oct 08, 2018 at 13:32:20 (UTC)
Goto Top
tasklist /FI "IMAGENAME eq cmd.exe"

Gruß speedlink
Member: Melmacker
Melmacker Oct 08, 2018 updated at 13:35:16 (UTC)
Goto Top
Danke schon mal speedlink dafür aber kann man das auch irgendwie in eine IF Abfrage packen?
Also:
IF %CMDFENSTER%==2 goto Test


Gruß Melmacker
Mitglied: 137289
137289 Oct 08, 2018 at 13:36:21 (UTC)
Goto Top
For Schleife drum bauen.
Member: Melmacker
Melmacker Oct 08, 2018 at 13:37:32 (UTC)
Goto Top
Ist dann wie bei deinem Beispiel IMAGENAME die Variable?
Mitglied: 137289
137289 Oct 08, 2018 at 13:39:15 (UTC)
Goto Top
Nein, lesen:
tasklist /?
Member: Melmacker
Melmacker Oct 08, 2018 at 13:41:59 (UTC)
Goto Top
Okay aber wie bekomme ich denn dann die Anzahl in eine Variable?
Mitglied: 137289
137289 Oct 08, 2018 at 13:43:38 (UTC)
Goto Top
Hab ich oben geschrieben, mach einfach eine For-Schleife drum, wie immer in solchen Fällen.
Member: Melmacker
Melmacker Oct 08, 2018 at 13:46:34 (UTC)
Goto Top
Kannst du mir vielleicht so eine For-Schleife mal als Beispiel machen?
Weil damit habe ich mich noch nicht wirklich großartig beschäftigt.
Mitglied: 137289
Solution 137289 Oct 08, 2018 at 13:49:22 (UTC)
Goto Top
@echo off
set "cnt="  
for /f "delims=" %%a in ('tasklist /FI "IMAGENAME eq cmd.exe" ^|find /c "cmd.exe"') do set cnt=%%a  
echo %cnt%
Member: Melmacker
Melmacker Oct 08, 2018 at 13:50:14 (UTC)
Goto Top
Danke :D