Changes

Firefox ext install downloads

3,362 bytes added, 17:20, 6 December 2011
clean-extensions.cmd for removing all old versions of an extension
reg delete "%key%" /v "%id%" /f
%return%
</source>
===packages/mozilla/clean-extensions.cmd===
<source lang="dos">
:: Mozilla extension installation demo script for Firefox and Thunderbird versions
:: based on Gecko 1.9+ from which the -install-global-extension command line option
:: has been removed. This script must be run from a Windows account with local
:: administrative rights. The extensions it installs can be run immediately by
:: limited users.
::
:: Falko Trojahn <falko (at) trojahn (dot) de> 01-May-2010
:: adapted from
:: Stephen Thomas <flabdablet (at) gmail.com> 31-Jan-2010
::
:: This is free software. Do whatever you want with it except hold me accountable
:: for the grief it will undoubtedly cause you. If you improve it, I'd like to hear
:: from you.
 
 
set mozextn=call :mozextn
set return=goto :eof
set rmdir=rmdir /s /q
set xpidir=c:\netinst
set zip="%ProgramFiles%\7-Zip\7z.exe"
 
:: :: give args on command line
:: Firefox myextension myextname
:: Thunderbird myextension myextname
:: (myextension without .xpi)
:: (myextname without VERSION and .xpi)
%mozextn% %1 %2 %3
%return%
 
 
 
:: REMOVE a Mozilla extension XPI package from a system-wide folder, and delete
:: the registry key required to tell the Mozilla app it's there.
::
:: Uses the same root folder for all packages regardless of whether they are
:: intended for Firefox or Thunderbird; this allows both apps to share disk space
:: for any extensions they have in common.
::
:: If there's already a folder in "%ProgramFiles%\Mozilla %appname%\extensions"
:: named for the ID of the extension being installed, or if the registry key
:: already exists and points to a different folder from the new one, the old
:: folders are deleted before the registry key is updated.
::
:: Parameters:
::
:: %1: app name (Firefox or Thunderbird)
:: %2: XPI package name, without trailing .xpi; also used to name the
:: installation folder.
::
:: Returns errorlevel 0 if installation worked, 1 if not.
::
:: Uses a totally unsound hack to extract the package ID from its install.rdf
:: file; will break horribly if the first <em:id> XML tag encountered does not
:: belong to the package ID, or if <em:id>package-id</em:id> is not all on
:: one line. If you'd rather use a proper XML parser instead, be my guest. If
:: it's really easy to do, let me know.
 
:mozextn
if exist "%ProgramFiles%\Mozilla Firefox\firefox.exe" goto :nurXP
if not exist "%ProgramFiles(x86)%\Mozilla Firefox\firefox.exe" %return%
:nur32
set extnroot=%CommonProgramFiles(x86)%\Mozilla Shared\Extensions
if not exist "%extnroot%" mkdir "%extnroot%"
if errorlevel 1 %return%
set key=HKLM\Software\Wow6432Node\Mozilla\%1\Extensions
 
 
goto nextall
:nurXP
set extnroot=%CommonProgramFiles%\Mozilla Shared\Extensions
if not exist "%extnroot%" mkdir "%extnroot%"
if errorlevel 1 %return%
set key=HKLM\Software\Mozilla\%1\Extensions
 
:nextall
 
set extndir=%extnroot%\%2
 
for /f "skip=2 tokens=*" %%L in ('find "<em:id>" "%extndir%\install.rdf"') do @(
set line="%%L"
goto :mozextn1
)
 
 
:mozextn1
set id=%line:~8,-9%
if "%id%"=="" (
verify error 2>nul
goto : clean
)
 
 
for /f "skip=4 tokens=2*" %%A in ('reg query "%key%" /v "%id%"') do set olddir=%%B
if "%olddir%"=="%extndir%" if exist "%olddir%" %rmdir% "%olddir%"
 
reg delete "%key%" /v "%id%" /f
 
:clean
for /f "tokens=*" %%i in ('dir /ad /b "%extnroot%\%3*"') do rmdir "%extnroot%\%%i" /s /q
 
%return%
</source>
66
edits