Boria138
16-08-2021, 17:26
Как сделать так что бы tasklist искал сразу несколько процессов например у нас есть условный блокнот я хочу открывать его через cmd но только если не открыт калькулятор или paint или же блокнот уже не запущен
@echo off
TIMEOUT /T 5
Set process1=paint.exe calc.exe
set process2=notepad.exe
tasklist /FI "ImageName EQ %process2%" | find /I "%process2%"
If %errorlevel% NEQ 1 goto :ex
:first
tasklist /FI "ImageName EQ %process1%" | find /I "%process1%"
If %errorlevel% NEQ 0 goto :first
taskkill /f /im %process2%
:first
tasklist /FI "ImageName EQ %process2%" | find /I "%process2%"
If %errorlevel% NEQ 1 goto :first
:go
tasklist /FI "ImageName EQ %process1%" | find /I "%process1%"
If %errorlevel% NEQ 1 goto :go
start notepad.exe
goto :first
:ex
exit
@echo off
TIMEOUT /T 5
Set process1=paint.exe calc.exe
set process2=notepad.exe
tasklist /FI "ImageName EQ %process2%" | find /I "%process2%"
If %errorlevel% NEQ 1 goto :ex
:first
tasklist /FI "ImageName EQ %process1%" | find /I "%process1%"
If %errorlevel% NEQ 0 goto :first
taskkill /f /im %process2%
:first
tasklist /FI "ImageName EQ %process2%" | find /I "%process2%"
If %errorlevel% NEQ 1 goto :first
:go
tasklist /FI "ImageName EQ %process1%" | find /I "%process1%"
If %errorlevel% NEQ 1 goto :go
start notepad.exe
goto :first
:ex
exit