Im a newbie in the cmd, and if you can just help me to do the batch while for Windows. This program must check the process while script is opened. If it doesn`t launched it will be open. If you can help me, just show me a code and explain how it works, please.
Asked
Active
Viewed 562 times
1
-
1And you can take a look here too ==> [Check if a process is running or not?](https://stackoverflow.com/questions/23266509/check-if-a-process-is-running-or-not?answertab=active#tab-top) – Hackoo Mar 04 '21 at 16:49
1 Answers
0
I asked before this question here Check if a process is running or not?
And here is a little tweak to run it in loop :
@echo off
Title How to do the loop which can check the process by the bat file
Color 0B
Set "MyProcess=Notepad.exe"
:CheckProcess_in_Loop
cls
Tasklist /NH /FI "imagename eq %MyProcess%" 2>nul |find /i "%MyProcess%" >nul
If not errorlevel 1 (Echo "%MyProcess%" is running !) else (start "" "%MyProcess%")
@REM Make a Timeout with 30 seconds
Timeout /T 30 /NoBreak>nul
Goto CheckProcess_in_Loop

Hackoo
- 18,337
- 3
- 40
- 70