'Delete history for all browsers with Batch file
I am trying to delete the history of IE, FireFox, Chrome and Opera using a batch file when staff log in. Below is what I have and it works but it also clears the bookmarks and preferences of Chrome and I think Firefox. How do I just clear the history without clearing bookmarks and preferences. Any help would be great, thank you.
@echo off
rem IE
taskkill /F /IM iexplore.exe
start "" "C:\Windows\System32\rundll32.exe" InetCpl.cpl,ClearMyTracksByProcess 255
:: Parse the Local AppData sub path
call :Expand xAppData "%%LocalAppData:%UserProfile%=%%"
set "xFirefox=\mozilla\firefox\profiles"
set "xChrome=\google\chrome\user data"
set "xOpera1=\Local\Opera\Opera"
set "xOpera2=\Roaming\Opera\Opera"
:: Start at the User directory
pushd "%UserProfile%\.."
taskkill /F /IM firefox.exe
taskkill /F /IM chrome.exe
taskkill /F /IM opera.exe
:: Loop through the Users
for /D %%D in (*) do if exist "%%~fD%xAppData%" (
rem Check for Firefox
if exist "%%~fD%xAppData%%xFirefox%" (
rd /s /q "%%~fD%xAppData%%xFirefox%"
)
rem Check for Chrome
if exist "%%~fD%xAppData%%xChrome%" (
rd /s /q "%%~fD%xAppData%%xChrome%"
)
rem Check for Opera
if exist "%%~fD%xAppData%%xOpera1%" (
rd /s /q "%%~fD%xAppData%%xOpera1%"
)
if exist "%%~fD%xAppData%%xOpera2%" (
rd /s /q "%%~fD%xAppData%%xOpera2%"
)
)
popd
goto End
::::::::::::::::::::::::::::::
:Expand <Variable> <Value>
if not "%~1"=="" set "%~1=%~2"
goto :eof
:End
endlocal
pause
Solution 1:[1]
Couldn't you just replace the browser data folder with a blank one that still has the bookmarks?
Like...
rem Check for Firefox
if exist "%%~fD%xAppData%%xFirefox%" (
rd /s /q "%%~fD%xAppData%%xFirefox%"
robocopy /e "C:\somewhere\BlankFirefox" "%%~fD%xAppData%%xFirefox%"
)
rem Check for Chrome
if exist "%%~fD%xAppData%%xChrome%" (
rd /s /q "%%~fD%xAppData%%xChrome%"
robocopy /e "C:\somewhere\BlankChrome" "%%~fD%xAppData%%xChrome%"
)
rem Check for Opera
if exist "%%~fD%xAppData%%xOpera1%" (
rd /s /q "%%~fD%xAppData%%xOpera1%"
robocopy /e "C:\somewhere\BlankOpera1" "%%~fD%xAppData%%xOpera1%"
)
if exist "%%~fD%xAppData%%xOpera2%" (
rd /s /q "%%~fD%xAppData%%xOpera2%"
robocopy /e "C:\somewhere\BlankOpera2" "%%~fD%xAppData%%xOpera2%"
)
That way it just reverts it back to when they first logged on?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Technoguyfication |
