Skip to main content
The 2024 Developer Survey results are live! See the results
edited body; added 1 character in body
Source Link
Io-oI
  • 8.3k
  • 3
  • 13
  • 41
@echo off 

rem :: code until 
rem :: to kill any process

set "_kill=cmd.exe timeout.exe"
set "_title=Keep_Yourself_Alive"
<con: title <nul & title %_title%

pushd %__AppDir__% && for /f tokens^=1^,3delims^=^" %%i in ('
tasklist /v /fo csv ^|findstr /i "%_kill%"^|findstr /vi "%_title%"
')do 2>nul <con: taskkill.exe /f /pid %%j >nul | echo\Bye Bye %%j:%%i

<con: rem./ & shutdown /and /your /flags /here & popd 
rem :: more code came here, after to kill process ... 

  • I never realized that Shutdown were attentive to waiting for the Timeout good to know...

1. Assign a unique Title to your bat:

@echo off 
Title Keep_Yourself_Alive

2. List with For /F the process PID of each CMD and Timeout with Tasklist and Finsdtr:

for /f tokens^=3delims^=^" %%i in ('tasklist /v /fo csv|findstr "cmd.exe timeout.exe"... 

3. One additional Findstr can be used to list only PIDs that does not match your unique bat TaskkillTitle

... ^|findstr /vi "Keep_Yourself_Alive" ... 

4. Use Taskkill with PID to kill the entire CMD.exe + Timeout process (if running*)

... ')do taskkill /F /PID %%i

Additional resources:

@echo off 

rem :: code until 
rem :: to kill any process

set "_kill=cmd.exe timeout.exe"
set "_title=Keep_Yourself_Alive"
<con: title <nul & title %_title%

pushd %__AppDir__% && for /f tokens^=1^,3delims^=^" %%i in ('
tasklist /v /fo csv ^|findstr /i "%_kill%"^|findstr /vi "%_title%"
')do 2>nul <con: taskkill.exe /f /pid %%j >nul | echo\Bye Bye %%j:%%i

<con: rem./ & shutdown /and /your /flags /here & popd 
rem :: more code came here, after to kill process ... 

  • I never realized that Shutdown were attentive to waiting for the Timeout good to know...

1. Assign a unique Title to your bat:

@echo off 
Title Keep_Yourself_Alive

2. List with For /F the process PID of each CMD and Timeout with Tasklist and Finsdtr:

for /f tokens^=3delims^=^" %%i in ('tasklist /v /fo csv|findstr "cmd.exe timeout.exe"... 

3. One additional Findstr can be used to list only PIDs that does not match your unique Taskkill

... ^|findstr /vi "Keep_Yourself_Alive" ... 

4. Use Taskkill with PID to kill the entire CMD.exe + Timeout process (if running*)

... ')do taskkill /F /PID %%i

Additional resources:

@echo off 

rem :: code until 
rem :: to kill any process

set "_kill=cmd.exe timeout.exe"
set "_title=Keep_Yourself_Alive"
<con: title <nul & title %_title%

pushd %__AppDir__% && for /f tokens^=1^,3delims^=^" %%i in ('
tasklist /v /fo csv ^|findstr /i "%_kill%"^|findstr /vi "%_title%"
')do 2>nul <con: taskkill.exe /f /pid %%j >nul | echo\Bye Bye %%j:%%i

<con: rem./ & shutdown /and /your /flags /here & popd 
rem :: more code came here, after to kill process ... 

  • I never realized that Shutdown were attentive to waiting for the Timeout good to know...

1. Assign a unique Title to your bat:

@echo off 
Title Keep_Yourself_Alive

2. List with For /F the process PID of each CMD and Timeout with Tasklist and Finsdtr:

for /f tokens^=3delims^=^" %%i in ('tasklist /v /fo csv|findstr "cmd.exe timeout.exe"... 

3. One additional Findstr can be used to list only PIDs that does not match your unique bat Title

... ^|findstr /vi "Keep_Yourself_Alive" ... 

4. Use Taskkill with PID to kill the entire CMD.exe + Timeout process (if running*)

... ')do taskkill /F /PID %%i

Additional resources:

added 20 characters in body
Source Link
Io-oI
  • 8.3k
  • 3
  • 13
  • 41
@echo off 

rem :: code until 
rem :: to kill any process

set "_kill=cmd.exe timeout.exe"
set "_title=Keep_Yourself_Alive"
<con: title <nul & title %_title%

pushd %__AppDir__% && for /f tokens^=1^,3delims^=^" %%i in ('
tasklist /v /fo csv ^|findstr /i "%_kill%"^|findstr /vi "%_title%"
')do 2>nul <con: taskkill.exe /f /pid %%j >nul | echo\Bye Bye %%j:%%i

<con: rem./:: shutdown /your /flags /here& shutdown /and /your /flags /here & popd 
rem :: more code fromcame here, after to kill process ... 

  • I never realized that Shutdown were attentive to waiting for the Timeout good to know...

1. Assign a unique Title to your bat:

@echo off 
Title Keep_Yourself_Alive

2. List with For /F the process PID of each CMD and Timeout with Tasklist and Finsdtr:

for /f tokens^=3delims^=^" %%i in ('tasklist /v /fo csv|findstr "cmd.exe timeout.exe"... 

3. One additional Findstr can be used to list only PIDs that does not match your unique Taskkill

... ^|findstr /vi "Keep_Yourself_Alive" ... 

4. Use Taskkill with PID to kill the entire CMD.exe + Timeout process (if running*)

... ')do taskkill /F /PID %%i

Additional resources:

@echo off 

rem :: code until 
rem :: to kill any process

set "_kill=cmd.exe timeout.exe"
set "_title=Keep_Yourself_Alive"
<con: title <nul & title %_title%

pushd %__AppDir__% && for /f tokens^=1^,3delims^=^" %%i in ('
tasklist /v /fo csv ^|findstr /i "%_kill%"^|findstr /vi "%_title%"
')do 2>nul <con: taskkill.exe /f /pid %%j >nul | echo\Bye Bye %%j:%%i

<con: rem./:: shutdown /your /flags /here & popd 
rem :: more code from here, after to kill process... 

  • I never realized that Shutdown were attentive to waiting for the Timeout good to know...

1. Assign a unique Title to your bat:

@echo off 
Title Keep_Yourself_Alive

2. List with For /F the process PID of each CMD and Timeout with Tasklist and Finsdtr:

for /f tokens^=3delims^=^" %%i in ('tasklist /v /fo csv|findstr "cmd.exe timeout.exe"... 

3. One additional Findstr can be used to list only PIDs that does not match your unique Taskkill

... ^|findstr /vi "Keep_Yourself_Alive" ... 

4. Use Taskkill with PID to kill the entire CMD.exe + Timeout process (if running*)

... ')do taskkill /F /PID %%i

Additional resources:

@echo off 

rem :: code until 
rem :: to kill any process

set "_kill=cmd.exe timeout.exe"
set "_title=Keep_Yourself_Alive"
<con: title <nul & title %_title%

pushd %__AppDir__% && for /f tokens^=1^,3delims^=^" %%i in ('
tasklist /v /fo csv ^|findstr /i "%_kill%"^|findstr /vi "%_title%"
')do 2>nul <con: taskkill.exe /f /pid %%j >nul | echo\Bye Bye %%j:%%i

<con: rem./ & shutdown /and /your /flags /here & popd 
rem :: more code came here, after to kill process ... 

  • I never realized that Shutdown were attentive to waiting for the Timeout good to know...

1. Assign a unique Title to your bat:

@echo off 
Title Keep_Yourself_Alive

2. List with For /F the process PID of each CMD and Timeout with Tasklist and Finsdtr:

for /f tokens^=3delims^=^" %%i in ('tasklist /v /fo csv|findstr "cmd.exe timeout.exe"... 

3. One additional Findstr can be used to list only PIDs that does not match your unique Taskkill

... ^|findstr /vi "Keep_Yourself_Alive" ... 

4. Use Taskkill with PID to kill the entire CMD.exe + Timeout process (if running*)

... ')do taskkill /F /PID %%i

Additional resources:

added 126 characters in body
Source Link
Io-oI
  • 8.3k
  • 3
  • 13
  • 41
@echo off 

rem :: code until 
rem :: to kill any process

set "_kill=cmd.exe timeout.exe"
set "_title=Keep_Yourself_Alive"
<con: title <nul & title %_title%

pushd %__AppDir__% && for /f tokens^=1^,3delims^=^" %%i in ('
tasklist /v /fo csv ^|findstr /i "%_kill%"^|findstr /vi "%_title%"
')do 2>nul <con: taskkill.exe /f /pid %%j >nul | echo\Bye Bye %%j:%%i

<con: rem./:: shutdown /your /flags /here & popd 
rem :: more code from here, after to kill process... 

  • I never realized that Shutdown were attentive to waiting for the Timeout good to know...

1. Assign a unique Title to your bat:

@echo off 
Title Keep_Yourself_Alive

2. List with For /F the process PID of each CMD and Timeout with Tasklist and Finsdtr:

for /f tokens^=3delims^=^" %%i in ('tasklist /v /fo csv|findstr "cmd.exe timeout.exe"... 

3. One additional Findstr can be used to list only PIDs that does not match your unique Taskkill

... ^|findstr /vi "Keep_Yourself_Alive" ... 

4. Use Taskkill with PID to kill the entire CMD.exe + Timeout process (if running*)

... ')do taskkill /F /PID %%i

Additional resources:

@echo off 

rem :: code until 
rem :: to kill any process

set "_kill=cmd.exe timeout.exe"
set "_title=Keep_Yourself_Alive"
<con: title <nul & title %_title%

pushd %__AppDir__% && for /f tokens^=1^,3delims^=^" %%i in ('
tasklist /v /fo csv ^|findstr /i "%_kill%"^|findstr /vi "%_title%"
')do 2>nul <con: taskkill.exe /f /pid %%j >nul | echo\Bye Bye %%j:%%i

<con: rem./:: shutdown /your /flags /here & popd 
rem :: more code from here, after to kill process... 

  • I never realized that Shutdown were attentive to waiting for the Timeout good to know...

1. Assign a unique Title to your bat:

@echo off 
Title Keep_Yourself_Alive

2. List with For /F the process PID of each CMD and Timeout with Tasklist and Finsdtr:

for /f tokens^=3delims^=^" %%i in ('tasklist /v /fo csv|findstr "cmd.exe timeout.exe"... 

3. One additional Findstr can be used to list only PIDs that does not match your unique Taskkill

... ^|findstr /vi "Keep_Yourself_Alive" ... 

4. Use Taskkill with PID to kill the entire CMD.exe + Timeout process (if running*)

... ')do taskkill /F /PID %%i

Additional resources:

@echo off 

rem :: code until 
rem :: to kill any process

set "_kill=cmd.exe timeout.exe"
set "_title=Keep_Yourself_Alive"
<con: title <nul & title %_title%

pushd %__AppDir__% && for /f tokens^=1^,3delims^=^" %%i in ('
tasklist /v /fo csv ^|findstr /i "%_kill%"^|findstr /vi "%_title%"
')do 2>nul <con: taskkill.exe /f /pid %%j >nul | echo\Bye Bye %%j:%%i

<con: rem./:: shutdown /your /flags /here & popd 
rem :: more code from here, after to kill process... 

  • I never realized that Shutdown were attentive to waiting for the Timeout good to know...

1. Assign a unique Title to your bat:

@echo off 
Title Keep_Yourself_Alive

2. List with For /F the process PID of each CMD and Timeout with Tasklist and Finsdtr:

for /f tokens^=3delims^=^" %%i in ('tasklist /v /fo csv|findstr "cmd.exe timeout.exe"... 

3. One additional Findstr can be used to list only PIDs that does not match your unique Taskkill

... ^|findstr /vi "Keep_Yourself_Alive" ... 

4. Use Taskkill with PID to kill the entire CMD.exe + Timeout process (if running*)

... ')do taskkill /F /PID %%i

Additional resources:

added 751 characters in body
Source Link
Io-oI
  • 8.3k
  • 3
  • 13
  • 41
Loading
Post Undeleted by Io-oI
added 547 characters in body
Source Link
Io-oI
  • 8.3k
  • 3
  • 13
  • 41
Loading
Post Deleted by Io-oI
Source Link
Io-oI
  • 8.3k
  • 3
  • 13
  • 41
Loading