CMD/BAT - [решено] Очистка и удаление папок

Ответить
Аватара пользователя
rosalin

CMD/BAT - [решено] Очистка и удаление папок

Сообщение rosalin »

Ребята помогите поправить





Код:

Код: Выделить всё

SetLocal EnableExtensions
For /F "Tokens=2*" %%I In ('Reg Query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" /V ProfilesDirectory') Do Set Profiles=%%J
Call Set Profiles=%Profiles%
For /F "Delims=" %%I In ('Dir /B /AD-S-H "%Profiles%" ^| FindStr /V /B /I /C:"All Users"') Do (
Del /F /S /Q /a "%Systemdrive%\Temp\*.*"
Del /F /S /Q /a "%Profiles%\%%I\Local Settings\Temp\*.*"
Del /F /S /Q /a "%Profiles%\%%I\Local Settings\Temporary Internet Files\*.*"
call rd /s /q "%Profiles%\%%I\Local settings\Application data\1C\1Cv82\????????-????-????-????-????????????"
call md "%Profiles%\%%I\Local settings\Application data\1C\1Cv82\????????-????-????-????-????????????"

не получаться удалять папки по маске ????????-????-????-????-????????????, набор букв и цифр, например такой 40f9cf68-a6b1-421c-9d7d-39976cada901 у всех пользователей разный через дефис, нужно удалить папку и что в папке
Аватара пользователя
Georgio

Re: CMD/BAT - [решено] Очистка и удаление папок

Сообщение Georgio »

Код:

Код: Выделить всё

@echo off& setLocal enableextensions
for /f "tokens=2*" %%I in ('
 reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" /v ProfilesDirectory^| findstr /i ProfilesDirectory
') do (
 call pushd "%%J"
 for /f "delims=" %%K in ('dir /ad-h-s/b^| findstr /ivxc:"All Users"') do (
  pushd "%%K\Local Settings"
  del /a/f/s/q "Temp"
  del /a/f/s/q "Temporary Internet Files"
  pushd "Application data\1C\1Cv82"
  for /f "delims=" %%L in ('
   dir /ad/b "????????-????-????-????-????????????"^| findstr /rc:"^........-....-....-....-............$"
  ') do (
   rd /s/q "%%L"
   )
  popd& popd
  )
 popd
 )
del /a/f/s/q "%Systemdrive%\Temp"
endlocal& exit /b 0



Код в работе не проверял!
Ответить

Вернуться в «Скриптовые языки администрирования Windows»