Page 1 of 1

execute script when firefox closes

Posted: 25 Apr 2010 20:02
by nottheadmin
Hi, thie is my first post so hello everyone, i'm a systems engineer and mainly use linux.

I have a netbook here with ubuntu and windows 7 in a dual boot setup. What i like to do is share my firefox profile between the two so that i can have all my bookmarks and addons etc on both windows and ubuntu, it works very well and it's nice to have an identical firefox on both operating systems (in fact on any computer, osx, linux or windows that i use)

I've written a couple of Rsync scripts to keep it synchronised but i cant figured out how to make windows execute the script when firefoxshuts down?

in other words i just wasnt a .bat file to run when firefox is closed.

Any idea's how this can be done?

Re: execute script when firefox closes

Posted: 26 Apr 2010 05:25
by aGerman
Think you would need two endless loops to watch for the running processes using the TASKLIST command.
You could try this:

Code: Select all

@echo off

:: *lets minimize the window
@set "tmpVariable="||(set "tmpVariable=1"&start "%~dpnx0" /min cmd /c %0 %*&set "tmpVariable="&goto :eof)

:: *loop until firefox is opened
:loop1
tasklist /nh /fi "imagename eq firefox.exe"|findstr /b /i /l /c:"firefox.exe">nul &&goto loop2
ping -n 1 localhost>nul
goto loop1

:: *loop until firefox is closed
:loop2
tasklist /nh /fi "imagename eq firefox.exe"|findstr /b /i /l /c:"firefox.exe">nul ||goto ahead
ping -n 1 localhost>nul
goto loop2

:: *if firefox is closed:
:ahead
:: your stuff here, e.g.:
>>"test.txt" echo %date% %time% firefox is closed
start "" "test.txt"


Regards
aGerman