|
本帖最后由 窄口牛 于 2021-12-11 07:59 编辑
由于用批处理删除用户错误,残留注册表引起的
自己写了个带注册表删除的,但是执行有毛病,主要是wimc命令玩的有问题
看哪位帮忙修改下
- @echo off
- Setlocal enabledelayedexpansion
- reg query HKU\S-1-5-20>nul || echo;CreateObject^("Shell.Application"^).ShellExecute "%~f0", "", "", "runas", 1 > "%temp%\getadmin.vbs" && cscript //b "%temp%\getadmin.vbs" && exit /b & del "%temp%\getadmin.vbs" /f /q>nul 2>nul
- pushd "%CD%"&& CD /D "%~dp0"
- for /f "tokens=2 delims=" %%a in ('whoami') do set i=%%a
- wmic /output:%temp%\temp.csv useraccount get Name,sid /format:csv
- for /f "skip=2 tokens=2,3 delims=," %%a in ('type %temp%\temp.csv ^| findstr /v "%i% Guest"') do (
- net user %%a /delete
- rd C:\Users\%%a /s /q
- reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\%%b" /f
- reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\%%b" /f
- )
- del %temp%\temp.csv /q
- echo 完成
- pause>nul
复制代码
|
|