1

I need help with code for .bat file should do following operations:

  1. Exit Cisco Jabber application.

Delete files and folders from following locations:

%userprofile%\AppData\Roaming\Cisco\Unified Communications\Jabber
%userprofile%\AppData\Local\Cisco\Unified Communications\Jabber
%userprofile%\AppData\Local\Temp
  1. Reset IE

  2. Flush DNS cache.

    Below is the sample code I found from this forum.

@ECHO OFF
    
SET THEDIR0=C:\Users\lashley\AppData\Local\Temp\
    
Echo Deleting all files from %THEDIR0% DEL "%THEDIR0%\*" /F /Q /A
    
Echo Deleting all folders from %THEDIR0% FOR /F "eol=| delims=" %%I in ('dir "%THEDIR0%\*" /AD /B 2^>nul') do rd /Q /S "%THEDIR0%\%%I" @ECHO Folder deleted.
    
  
SET THEDIR1=C:\Users\saiku\Desktop\New folder\New folder\
    
Echo Deleting all files from %THEDIR1% DEL "%THEDIR1%\*" /F /Q /A
    
Echo Deleting all folders from %THEDIR1% FOR /F "eol=| delims=" %%I in ('dir "%THEDIR1%\*" /AD /B 2^>nul') do rd /Q /S "%THEDIR1%\%%I" @ECHO Folder deleted.
    
    
SET THEDIR2=C:\Users\saiku\Desktop\New folder\New folders\
    
    
Echo Deleting all files from %THEDIR2% DEL "%THEDIR2%\*" /F /Q /A
    
Echo Deleting all folders from %THEDIR2% FOR /F "eol=| delims=" %%I in ('dir "%THEDIR2%\*" /AD /B 2^>nul') do rd /Q /S "%THEDIR2%\%%I" @ECHO Folder deleted.
    
EXIT
  • Note: I had to manually run this .bat file as admin for this to work. Can this code be modified such way that it works with a single click?

  • Note2: I want this code to work on any computer irrespective of computer name or user account of the computer:

    Example:
    %userprofile%\AppData\Roaming\Cisco\Unified Communications
    I want Unified Communication folder to be deleted in this case

0

Check the comments in the code tagged with "REM":

@ECHO OFF
REM *Exit Cisco Jabber application.*
REM *Replace "notepad.exe" with the filename of the Jabber application*
SET processname=notepad.exe
tasklist | find /i %processname% && taskkill /im notepad.exe /F || echo process %processname% not running.

REM *Delete files*
REM *I think you have it to run as administrator because you want to access the TEMP folder.*
REM *As a work around you could change the access rights of this folder for all local users. Consider the security issues with this*
SET THEDIR0=%temp%    
Echo Deleting all files from %THEDIR0% DEL "%THEDIR0%\*" /F /Q /A
Echo Deleting all folders from %THEDIR0% FOR /F "eol=| delims=" %%I in ('dir "%THEDIR0%\*" /AD /B 2^>nul') do rd /Q /S "%THEDIR0%\%%I" @ECHO Folder deleted.
SET THEDIR1=%userprofile%\Desktop\New folder\New folder\
Echo Deleting all files from %THEDIR1% DEL "%THEDIR1%\*" /F /Q /A
Echo Deleting all folders from %THEDIR1% FOR /F "eol=| delims=" %%I in ('dir "%THEDIR1%\*" /AD /B 2^>nul') do rd /Q /S "%THEDIR1%\%%I" @ECHO Folder deleted.
SET THEDIR2=%userprofile%\Desktop\New folder\New folders\
Echo Deleting all files from %THEDIR2% DEL "%THEDIR2%\*" /F /Q /A
Echo Deleting all folders from %THEDIR2% FOR /F "eol=| delims=" %%I in ('dir "%THEDIR2%\*" /AD /B 2^>nul') do rd /Q /S "%THEDIR2%\%%I" @ECHO Folder deleted.


REM Reset IE
REM What do you mean with this exactly?
REM Do you want to reload a webpage or would restart the browser be enought?

REM Flush DNS
ipconfig /flushdns

EXIT
| improve this answer | |
  • Thank you. Reset IE - Reset Internet explorer settings from Internet options > Advance > Reset. – Lashely Innovations Aug 7 at 12:06
  • It is answered on above post. Thanks for all your help. – Lashely Innovations Aug 7 at 12:53
0
@Echo off & CD/d "%~dp0"

Set "_dir=Roaming,Local"
Echo\Killing iE and Jabber!...
Setlocal EnableDelayedExpansion

%:^(
For %%i in ("CiscoJabber.exe", "CiscoJabberPrt.exe",iexplore.exe
)do Rem./ & 2>nul >nul "%__APPDIR__%Taskkill.exe" /f /t /im %%~I

;Echo\Checking if still running... && for %%i in (CiscoJabber,iExplore
)do 2>nul "%__APPDIR__%Tasklist.exe" /nh |Find/i "%%i.exe" >nul && Goto %:^(

>nul 2>&1 "%__APPDIR__%RunDll32.exe" InetCpl.cpl,ClearMyTracksByProcess 4351

%:^)
(%__APPDIR__%Tasklist.exe |Find/i "CiscoJabber.exe" >nul || For %%i in (!_dir!)do (
   If /i exist "%UserProfile%\AppData\%%~i\Cisco\Unified Communications\Jabber\*" (
       CD /d "%UserProfile%\AppData\%%~i\Cisco\Unified Communications\Jabber\" && (
       cmd/v/c "Echo\Deleting: !cd! & RMdir/q/s "!cd!." & Echo\\Deleted: !cd!\" )))
       ) 2>nul & "%__APPDIR__%Tasklist.exe" |Find/i "CiscoJabber" >nul && Goto %:^(

;Rem./ && Echo\Deleting: %tmp% & 2>nul RMDir/q /s "%tmp%\." & Echo\\Deleted: %tmp%\
;Rem./ && "%__APPDIR__%IPConfig.exe" /flushdns|Find/i "DNS" & Endlocal && Goto=:EOF

  • Outputs:
Killing iE and Jabber!...
Checking if still running...
Deleting: C:\Users\ecker\AppData\Roaming\Cisco\Unified Communications\Jabber
\Deleted: C:\Users\ecker\AppData\Roaming\Cisco\Unified Communications\Jabber\
Deleting: C:\Users\ecker\AppData\Local\Cisco\Unified Communications\Jabber
\Deleted: C:\Users\ecker\AppData\Local\Cisco\Unified Communications\Jabber\
Deleting: C:\Users\ecker\AppData\Local\Temp
\Deleted: C:\Users\ecker\AppData\Local\Temp\
Successfully flushed the DNS Resolver Cache.

Obs.: 1 iE Commands Souces: @R L H answer

Obs.: 2 A suggestion with the for loop, in case you need several iE commands to reset/clean/remove:

For %%i in ( 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 4351, 8192
)do 2>nul >nul "%__APPDIR__%RunDll32.exe" InetCpl.cpl,ClearMyTracksByProcess %%i

   1 == Browsing History
   2 == Cookies
   4 == Temporary Internet Files
   8 == Offline favorites and download history
  16 == Form Data
  32 == Passwords
  64 == Phishing Filter Data
 128 == Web page Recovery Data
 256 == Do not Show GUI when running the cache clear
 512 == Do not use Multi-threading for deletion
1024 == Valid only when browser is in private browsing mode
2048 == Tracking Data
4096 == Data stored by add-ons
4351 == Delete all w/Data stored by add-ons
8192 == Preserves Cached data for Favorite websites

  • An alternative (conventional / slightly simpler) with the same outputs, would be:
@Echo off 

CD /d "%~dp0"
Setlocal EnableDelayedExpansion 

:to_kill_process
For %%i in (CiscoJabber.exe,CiscoJabberPrt.exe,iexplore.exe)do (
     "%__APPDIR__%Taskkill.exe" /f /t /im %%~i
    ) 2>nul >nul

Echo\Stop/Kill iE and/or CiscoJabber... & echo\

For %%i in (CiscoJabber.exe,CiscoJabberPrt.exe,iexplore.exe)do (
     "%__APPDIR__%tasklist.exe" /nh |Find/i "%%i.exe" 
    ) 2>nul >nul&& Goto :to_kill_process
    
<con: Set /p "=Resetting iExplorer." <nul && (
     "%__APPDIR__%RunDll32.exe" InetCpl.cpl,ClearMyTracksByProcess 4351
     ) && echo\ is Done..
echo\..done!

:to_del_folders
   ( 
     %__APPDIR__%Tasklist.exe |Find/i "CiscoJabber.exe" >nul 
    ) || (
     For %%i in (!_dir!) do If /i exist "%UserProfile%\AppData\%%~i\Cisco\Unified Communications\Jabber\*" (
        (
          CD /d "%UserProfile%\AppData\%%~i\Cisco\Unified Communications\Jabber\"
        ) && (
         Echo\ & cmd.exe /v:on /c "Echo\Deleting: !cd! & RMdir /q /s "!cd!." & Echo\\Deleted: !cd!\" 
        )
        )
        ) 2>nul
            
"%__APPDIR__%tasklist.exe" | Find/i "CiscoJabber" >nul && Goto :to_kill_process
       
Echo\ & Echo\Deleting: %tmp%

2>nul RMDir/q /s "%tmp%\."

Echo\\Deleted: %tmp%\ & Echo/

<con: Set /p "=Cleaning up DNsServerCache: " <nul 
"%__APPDIR__%ipconfig.exe" /flushdns |find/i "DNS"

Endlocal & Goto :EOF

  • Outputs:
Stop/Kill iE and/or CiscoJabber...

Resetting iExplorer...done

Deleting: C:\Users\ecker\AppData\Roaming\Cisco\Unified Communications\Jabber
\Deleted: C:\Users\ecker\AppData\Roaming\Cisco\Unified Communications\Jabber\

Deleting: C:\Users\ecker\AppData\Local\Cisco\Unified Communications\Jabber
\Deleted: C:\Users\ecker\AppData\Local\Cisco\Unified Communications\Jabber\

Deleting: C:\Users\ecker\AppData\Local\Temp
\Deleted: C:\Users\ecker\AppData\Local\Temp\

Cleaning up DNsServerCache: Successfully flushed the DNS Resolver Cache.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.