问题
I need a script (without delprof.exe) to remove windows xp profiles older than 1 year. I use CCleaner first to remove all temp files in windows and the user profile.
start /wait ccleaner.exe /auto
Then I want to remove profiles. But simply rmdir won't work.
回答1:
This should do it:
@echo off & setlocal
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set /a YYYYprev=%YYYY%-1
wmic path win32_userprofile where "not LocalPath like '%Admin%' and special=false and loaded=false and LastUseTime<'%YYYYPrev%%MM%%DD%'" delete
回答2:
Look like can edit the registry directly, use wmic, powershell, group policy, or 3rd party tools:
- windows-7-delprof-replacement-for-deleting-profiles
- how-do-i-delete-a-user-profile-on-a-windows-7-machine-that-is-part-of-a-domain
- http://support.microsoft.com/kb/156826
- delprof2
来源:https://stackoverflow.com/questions/21854651/batch-remove-old-profiles