清理远程用户.bat


#准备好包含用户名的txt,拉到bat上运行

@echo off
title 清理远程登录用户工具
setlocal enabledelaydexpansion
set userlist_path=%~dp0

rd "%WinDir\system32\test_permissions%" >NUL 2>NUL
md "%WinDir\system32\test_permissions%" 2>NUL || (echo 请使用管理员身份运行! && pause && exit)
rd "%WinDir\system32\test_permissions%" 2>NUL

echo 正在清理远程登录用户,请稍等。。。
for /f "delims= " %%i in (%userlist_path%user.txt) do (
net localgroup "Remote Desktop Users" %%i /delete >NUL 2>NUL
if !errorlevel! EQU 0 (
echo 【清理用户】 %%i 成功
)
)
pause

 

posted @ 2020-04-14 14:45  破仔  阅读(272)  评论(0编辑  收藏  举报