@echo off setlocal set uon=N for /f "Tokens=*" %%i in ('dtreg -Quiet -ListValue "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell"') do call :shell "%%i" endlocal&set uon=%uon% goto end :shell set sv=%1 set sv=%sv:"REG_SZ =% set sv=%sv:"=% for /f "Tokens=2" %%i in ('tlist') do call :find "%%i" goto end :find if "%uon%"=="Y" goto end if /i "%sv%"==%1 set uon=Y :end