Firefox & Chrome history deleter

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
hckR360
Posts: 5
Joined: 24 Dec 2016 20:48

Firefox & Chrome history deleter

#1 Post by hckR360 » 26 Dec 2016 16:56

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
Attachments
deleter.zip
(661 Bytes) Downloaded 353 times
Last edited by hckR360 on 12 Jan 2017 12:14, edited 2 times in total.

pcjunki
Posts: 2
Joined: 30 Dec 2016 13:26

Re: Firefox & Chrome history deleter

#2 Post by pcjunki » 30 Dec 2016 13:30

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"

Sounak@9434
Posts: 100
Joined: 16 Dec 2016 22:31

Re: Firefox & Chrome history deleter

#3 Post by Sounak@9434 » 31 Dec 2016 01:30

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.

hckR360
Posts: 5
Joined: 24 Dec 2016 20:48

Re: Firefox & Chrome history deleter

#4 Post by hckR360 » 12 Jan 2017 12:14

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

Sounak@9434
Posts: 100
Joined: 16 Dec 2016 22:31

Re: Firefox & Chrome history deleter

#5 Post by Sounak@9434 » 13 Jan 2017 01:38

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

Sounak@9434
Posts: 100
Joined: 16 Dec 2016 22:31

Re: Firefox & Chrome history deleter

#6 Post by Sounak@9434 » 21 Jan 2017 12:55

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
)

Post Reply