Batch remove old profiles

断了今生、忘了曾经 提交于 2021-02-08 12:01:18

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!