asked on
ForceLogoff.bat contains:
@echo off
if {%1}=={} @echo Syntax ForceLogoff Exceptions&goto :EOF
if not exist %1 @echo Syntax ForceLogoff Exceptions - %1 does NOT exist.&goto :EOF
setlocal ENABLEDELAYEDEXPANSION
set except=%1
set dom=%USERDOMAIN%
for /f "Tokens=1" %%c in ('net view /domain:%dom%^|findstr /L /C:"\\"^|findstr /L /V /C:"\\%ComputerName%"') do (
for /f "tokens=*" %%u in ('psloggedon -L %%c^|findstr /L /C:"/"') do (
set work1=%%u
call set work2=!!work1:%dom%=!!
if "!work2!" NEQ "!work1!" for /f "Tokens=*" %%i in ('@echo %%c^|Findstr /L /I /V /G:%except%') do (
psshutdown -o %%i
)
)
)
endlocal