批处理将非administrator用户全部禁掉的代码
作者:
原理就是利用批处理net user获取的所有用户列表,然后判断是不是administrator用户,不是的全部禁掉
本地测试还可以,要保证你的电脑的默认用户是adminstrator而且没有修改用户名,要不就会无法登陆电脑了。
@echo off
:: by SKB
setlocal enabledelayedexpansion
net user|find /v "命令成功完成" >tmp.txt
echo.>tmp2.txt
for /f "skip=4 tokens=1" %%i in (tmp.txt) do echo %%i >>tmp2.txt
for /f "skip=4 tokens=2" %%i in (tmp.txt) do echo %%i >>tmp2.txt
for /f "skip=4 tokens=3" %%i in (tmp.txt) do echo %%i >>tmp2.txt
for /f "skip=1" %%i in (tmp2.txt) do (
if not %%i==Administrator net user %%i /active:no
)
del tmp.txt
del tmp2.txt
echo 完成
pause
复制代码 代码如下:
@echo off
:: by SKB
setlocal enabledelayedexpansion
net user|find /v "命令成功完成" >tmp.txt
echo.>tmp2.txt
for /f "skip=4 tokens=1" %%i in (tmp.txt) do echo %%i >>tmp2.txt
for /f "skip=4 tokens=2" %%i in (tmp.txt) do echo %%i >>tmp2.txt
for /f "skip=4 tokens=3" %%i in (tmp.txt) do echo %%i >>tmp2.txt
for /f "skip=1" %%i in (tmp2.txt) do (
if not %%i==Administrator net user %%i /active:no
)
del tmp.txt
del tmp2.txt
echo 完成
pause