working from home on my private PC via Citrix with web sessions, skype sessions, ... I'd like to make sure that I've gained privacy after end of work. I've figured out the following batch script to close all job related taskbar tasks by one double click. It's kind of brute force, but a single taskkill (therefor) hasn't done the job on certain (nested) processes in the past. Any suggestions for improvements?
Translations:
ist beendet = e.g. = is terminated
ist nicht beendet = e.g. = is not terminated
Best Regards Matt
GetPrivacy_v4.bat
@ECHO OFF
ECHO ############# STARTING ###############
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
SET FILE = ""
SET/A ACTFILE = 0
SET/A MAXFILE = 0
SET/A TRIES = 1
SET "SUCCESS=TRUE"
set "LIST=(msedge.exe AuthManSvr.exe AnyDesk.exe wfcrun32.exe Concentr.exe CtxWebBrowser.exe
SelfService.exe SelfServicePlugin.exe Skype.exe TeamViewer_service.exe
g2mlauncher.exe g2mcomm.exe redirector.exe dropbox.exe Teams.exe)"
for %%x in %LIST% do SET/A MAXFILE += 1
for %%x in %LIST% do (
SET/A ACTFILE += 1
SET FILE=%%x
SET "SUCCESS=TRUE"
SET/A TRIES=1
FOR /L %%T IN (1,1,5) DO (
IF !TRIES! LEQ 5 (
start /MIN taskkill /F /T /IM !FILE! 2>&0
FOR /f "tokens=1-6,* delims=. " %%a IN ('TASKLIST') DO (
IF "%a%" == "!FILE!" SET "SUCCESS=FALSE"
)
IF "%SUCCESS%" == "TRUE" (
SET/A TRIES = 6
) ELSE (
SET/A TRIES = %%T
)
)
)
IF !TRIES! == 6 (
IF "%SUCCESS%" == "TRUE" ( ECHO !ACTFILE!/!MAXFILE!: !FILE! ist beendet )
IF "%SUCCESS%" == "FALSE" ( ECHO !ACTFILE!/!MAXFILE!: !FILE! ist nicht beendet )
)
)
ECHO ############### DONE #################
PAUSE