Написан для Windows 7 и Windows XP, но его можно легко модифицировать, изменив проверку версии ОС. Проверяет запущен ли MS Lync / Communicator.
@echo off setlocal echo Please make sure MS Outlook and MS Lync are closed. pause :Outlookcheck for /f "skip=3 Tokens=1" %%a in ('tasklist /fi "imagename eq outlook.exe"') do ( if %errorlevel% EQU 0 (goto outexit) else (goto Comcheck) ) :Comcheck set %errorlevel%=1 for /f "skip=3 Tokens=1" %%a in ('tasklist /fi "imagename eq communicator.exe"') do ( if %errorlevel% EQU 1 (goto install) ) for /f "skip=3 Tokens=1" %%a in ('tasklist /fi "imagename eq lync.exe"') do ( if %errorlevel% EQU 0 (goto comexit) else (goto install) ) :install set regexe=%SystemRoot%\System32\Reg.exe set vkey=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion set vvalue="CurrentBuildNumber" for /f "Tokens=3*" %%v in ('%regexe% QUERY "%vkey%" /v %vvalue% 2^>NUL') do set winver=%%v if %winver% == 7600 (goto win7) else (goto winxp) echo %winver% pause :win7 rd "%USERPROFILE%\AppData\Local\Microsoft\Outlook\Offline Address Books\" /s /q if %ERRORLEVEL% EQU 0 (goto Success) else (goto NoSuccess) :winxp del "%userprofile%\Local Settings\Application Data\Microsoft\Outlook\*.oab" /f /s /q if %ERRORLEVEL% EQU 0 (goto Success) else (goto NoSuccess) :Success echo. echo Address books have been deleted... ping -n 5 localhost > nul exit :NoSuccess echo. echo ! Can't delete files - they may be occupied by another process ! pause exit /b :comexit echo. echo Lync is still running. Please close it and press any key! pause goto Comcheck :outexit echo. echo Outlook is still running. Please close it and press any key! pause goto Outlookcheck endlocal