Page 1 of 1

Firefox & Chrome history deleter

Posted: 26 Dec 2016 16:56
by hckR360
Save time by using my Firefox & Chrome history deleter.

code:

Code: Select all

@echo off
tasklist | find "firefox.exe" >nul 2>nul
if "%errorlevel%" == "0" (goto ffxopen) else (goto ffxclosed)
:ffxopen:
set /p "ffxinput=the command cannot be executed because firefox is running. close it? [y/n]"
if "%ffxinput%" == "y" (goto yf) else (if "%ffxinput%" == "n" (goto nf) else (echo unknown command: %ffxinput%))
:yf:
taskkill /IM firefox.exe /f
goto ffxclosed
:nf:
goto chrome
:ffxclosed:
pushd C:\
cd C:\Users\%USERNAME%\AppData\Roaming\Mozilla\Firefox\Profiles >nul 2>nul
if "%errorlevel%" == "1" (goto ffxui) else (goto ffxi)
:ffxui:
echo firefox is not installed.
goto chrome
:ffxi:
FOR /D /r %%G in ("*.default") DO cd %%G
del places.sqlite >nul 2>nul
:chrome:
tasklist | find "chrome.exe" >nul 2>nul
if "%errorlevel%" == "0" (goto chopen) else (goto chclosed)
:chopen:
set /p "chinput=the command cannot be executed because chrome is running. close it? [y/n]"
if "%chinput%" == "y" (goto cy) else (if "%chinput%" == "n" (goto cn) else (echo unknown command: %chinput%))
:cy:
taskkill /IM chrome.exe /f
goto chclosed
:cn:
goto :eof
:chclosed:
pushd C:\
cd C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data\Default >nul 2>nul
if "%errorlevel%" == "1" (goto chni) else (goto chi)
:chni:
echo chrome is not installed
goto :eof
:chi:
del History >nul 2>nul

Re: Firefox & Chrome history deleter

Posted: 30 Dec 2016 13:30
by pcjunki
you could also do it this way in just one line...

forfiles /s /p %userprofile%\appdata /m Mozilla /c "cmd /c rd /s /q @path"

Re: Firefox & Chrome history deleter

Posted: 31 Dec 2016 01:30
by Sounak@9434
You should add a tasklist check to check if the browser is closed and also a 'if exist' check to know if the browser is installed or not as let's say the person has Chrome installed but not Firefox. As your script deletes Firefox history first it would print 'system cannot find the file path specified' and then for command would start deleting files from c and all it's subfolders.

Re: Firefox & Chrome history deleter

Posted: 12 Jan 2017 12:14
by hckR360
Sounak@9434 wrote:You should add a tasklist check to check if the browser is closed and also a 'if exist' check to know if the browser is installed or not as let's say the person has Chrome installed but not Firefox. As your script deletes Firefox history first it would print 'system cannot find the file path specified' and then for command would start deleting files from c and all it's subfolders.

@Sounak@9434 see edit

Re: Firefox & Chrome history deleter

Posted: 13 Jan 2017 01:38
by Sounak@9434
hckR360 wrote:
Sounak@9434 wrote:You should add a tasklist check to check if the browser is closed and also a 'if exist' check to know if the browser is installed or not as let's say the person has Chrome installed but not Firefox. As your script deletes Firefox history first it would print 'system cannot find the file path specified' and then for command would start deleting files from c and all it's subfolders.

@Sounak@9434 see edit

:D At least it is much better to me now

Re: Firefox & Chrome history deleter

Posted: 21 Jan 2017 12:55
by Sounak@9434
Though you have made your script unnecesserily long and slow. Try using "if errorlevel 1 command" instead of 'if "%errorlevel%" == "1" command'
And also avoid using so many goto :label and use

Code: Select all

if errorlevel 1 (
 echo.Whatever
) else (
 echo.Something else
)