Archive: Installer for Firefox Toolbar


Installer for Firefox Toolbar
Hi Friends!
I have made an toolbar extension for firefox, and i want to make a installer for it, now my back end is in MySQL and toolbar is coded in JS and XUL now as you might know firefox extensions are installed by opening firefox and then opening the .xpi file with firefox to install it, now how do i make firefox launch from NSIS intaller and let it open .xpi file which would install the toolbar for me. also how would i include the MySQL database files in the installer.

Thanks.


You may want to take a look here


Thnks Red wine, but still i am in a dilemma of how to install my MySQL database on the users machine so that the toolbar is able to call the database.
Thanks.


how to install my MySQL database...
I'd suggest forum and wiki search :-)

Hey thanks... :)))
but do i need to install MySQL on target machines or just my MySQL file.


I'd be surprised if you needed to include the database with the installer; why not let users set it up themselves? They may even already have a copy installed.


Hi Rob!
so it means that if they dont have MySQL on their machines, i should give them a message to install MySQL first on their machines and then put up my database files in the installer? or i should make a execwait from the installer to install MySQL on their machines, but that brings up the issues of passwords etc for MySQL.

Thanks.


Well I don't know the details of your situation, but I'd be tempted to just say, "This needs MySQL, install it before you run this installer." Just offload it to the user :)

But your application's raison d'etre may be having MySQL included. It's a management decision :)


Thanksss Rob!


Hi!
here is my script but is not launching Firefox and hence the .xpi is not installed, pls help me correct it.
Thanks.
!define APPNAME "NetTrust"
!define APPNAMEANDVERSION "NetTrust 1.0."

Name "${APPNAMEANDVERSION}"
OutFile "NetTrustSetup.exe"
BrandingText "NetTrust"

;Flags
XPStyle on
!include "MUI.nsh"

!define MUI_ABORTWARNING

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "license.txt"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
;page custom Dotnet,DirectX
!insertmacro MUI_PAGE_FINISH


!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_RESERVEFILE_LANGDLL


;Set the default Installation Directory
InstallDir "$PROGRAMFILES\Nettrust"

Function .onInit
MessageBox MB_YESNO "This will install NetTrust on your System. Do you wish to continue?" IDYES true
Abort

true:

ReadRegStr $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe" ""
StrCmp $1 "" NoFireFox ok

NoFireFox:
MessageBox MB_OK|MB_ICONSTOP "FireFox wasn't found on your system, Please install the latest version of Firefox from http://www.mozilla.com/firefox. Setup will now Exit."
Abort

ok:

!insertmacro MUI_LANGDLL_DISPLAY

InitPluginsDir

functionend

Section "NetTrust" Section1;

; Set output path to the installation directory. Also sets the working
; directory for shortcuts
SetOutPath $INSTDIR\

nsExec::Exec '"C:\Program Files\Mozilla Firefox\firefox.exe" -install-global-extension "nt.xpi"'


File nt.exe
File readme.txt


WriteUninstaller $INSTDIR\UninstallNetTrust.exe

; // CREATE SHORT CUTS

CreateShortCut "$DESKTOP\NetTrust.lnk" "$INSTDIR\nt.exe"
CreateDirectory "$SMPROGRAMS\NetTrust"
CreateShortCut "$SMPROGRAMS\NetTrust\Run NetTrust.lnk" "$INSTDIR\nt.exe"
CreateShortCut "$SMPROGRAMS\NetTrust\Uninstall NetTrust.lnk" "$INSTDIR\UninstallNetTrust.exe"

; // END CREATING SHORTCUTS

; //CREATE REGISTRY KEYS FOR ADD/REMOVE PROGRAMS IN CONTROL PANEL

WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NetTrust" "NetTrust"\
"NetTrust (remove only)"

WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NetTrust" "UninstallString" \
"$INSTDIR\UninstallNetTrust.exe"

; // END CREATING REGISTRY KEYS

MessageBox MB_OK "NetTrust was successfully installed on your Computer."

SectionEnd



Section "Uninstall"
; remove all the files and folders
Delete $INSTDIR\UninstallNetTrust.exe ; delete self
Delete $INSTDIR\nt.xpi
Delete $INSTDIR\nt.exe
Delete $INSTDIR\readme.txt


RMDir $INSTDIR

; now remove all the startmenu links
Delete "$SMPROGRAMS\NetTrust\Run NetTrust.lnk"
Delete "$SMPROGRAMS\NetTrust\Uninstall NetTrust.lnk"
RMDIR "$SMPROGRAMS\NetTrust"

; Now delete registry keys
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\NetTrust"
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\NetTrust"

SectionEnd


This line:

nsExec::Exec '"C:\Program Files\Mozilla Firefox\firefox.exe" -install-global-extension "nt.xpi"'

should actually have the value you pulled from the registry, not referring to an absolute path.

nsExec::Exec '"$0" -install-global-extension "nt.xpi"'
or
nsExec::Exec '"$0\firefox.exe" -install-global-extension "nt.xpi"'


<<nsExec::Exec '"$0" -install-global-extension "nt.xpi"' >>
shall it not be $1 as i am getting registry value in $1 and not in $0?


True. Sorry, it's just that I always use $0 as my first variable. It should be $1 in your case.


Does this "nt.xpi" exist on target, or you're going to extract it?
I think a path to the file is missing.


hi !!
nt.xpi is on my machine, and also i am going to put one nt.xpi on the target machine by simply
file nt.xpi before the exec statement, would it work?
as regards the path it is in the same folder as the .nsi file so i think it should work.
Thanks.


Yes,
SetOutPath $INSTDIR
File .....
File .....
File nt.xpi
nsExec::Exec '"$1" -install-global-extension "$INSTDIR\nt.xpi"'


It works guyssssssssssss!!

THANK YOU ALL!!:D


please helpppppp
sorry to bug you again guys.. but the application installed correctly on one machine but one another one, it just throws up the firefox browser without installing the toolbar, please take a look at my final script and please help me...

!define APPNAME "NetTrust"
!define APPNAMEANDVERSION "NetTrust 1.1."

Name "${APPNAMEANDVERSION}"
OutFile "NetTrust.exe"
BrandingText "NetTrust"

!include "MUI.nsh"

!define MUI_ABORTWARNING

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "license.txt"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_LANGUAGE "English"

!insertmacro MUI_RESERVEFILE_LANGDLL



Function .onInit
;MessageBox MB_YESNO "This will install NetTrust on your System. Do you wish to continue?" IDYES gogogo
;Abort

;gogogo:

ReadRegStr $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe" ""
StrCmp $1 "" NoFireFox ok

NoFireFox:
MessageBox MB_OK|MB_ICONSTOP "FireFox wasn't found on your system, Please install the latest version of Firefox from http://www.mozilla.com/firefox. Setup will now Exit"
Abort

ok:

!insertmacro MUI_LANGDLL_DISPLAY

InitPluginsDir


functionend

Section "" ; A "useful" name is not needed as we are not installing separate components

; Set output path to the installation directory. Also sets the working
; directory for shortcuts
SetOutPath $INSTDIR\

File nt.xpi
File nt.exe
File readme.txt
nsExec::Exec '"$1"' -install-global-extension "$INSTDIR\nt.xpi"


WriteUninstaller $INSTDIR\UninstallNetTrust.exe

; ///////////////// CREATE SHORT CUTS //////////////////////////////////////

CreateDirectory "$SMPROGRAMS\NetTrust"


CreateShortCut "$SMPROGRAMS\NetTrust\Run NetTrust.lnk" "$INSTDIR\nt.exe"


CreateShortCut "$SMPROGRAMS\NetTrust\Uninstall NetTrust.lnk" "$INSTDIR\UninstallNetTrust.exe"

; ///////////////// END CREATING SHORTCUTS //////////////////////////////////

; //////// CREATE REGISTRY KEYS FOR ADD/REMOVE PROGRAMS IN CONTROL PANEL /////////

WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NetTrust" "NetTrust"\
"NSIS Example Application 1 (remove only)"

WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NetTrust" "UninstallString" \
"$INSTDIR\UninstallNetTrust.exe"

; //////////////////////// END CREATING REGISTRY KEYS ////////////////////////////

MessageBox MB_OK "Installation was successful."

SectionEnd



Section "Uninstall"
; remove all the files and folders
Delete $INSTDIR\UninstallNetTrust.exe ; delete self
Delete $INSTDIR\nt.xpi
Delete $INSTDIR\nt.exe
Delete $INSTDIR\readme.txt


RMDir $INSTDIR

; now remove all the startmenu links
Delete "$SMPROGRAMS\NetTrust\Run NetTrust.lnk"
Delete "$SMPROGRAMS\NetTrust\Uninstall NetTrust.lnk"
RMDIR "$SMPROGRAMS\NetTrust"

; Now delete registry keys
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\NetTrust"
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\NetTrust"

SectionEnd


The path part of the plugin call must be surrounded by quotes. This includes the parameters.
I'm not sure how it worked at all to be honest, unless the readme isn't telling me something.

nsExec::Exec '"$1" -install-global-extension "$INSTDIR\nt.xpi"'

-Stu


It does n't even launch firefox if quotes are put this way.


perhaps this?
nsExec::Exec '"$1 -install-global-extension" "$INSTDIR\nt.xpi"'


:o Nope that doesnt help too... i guesss we just need to launch firefox and present it with a .xpi file so that the toolbar file, nt.xpi installs itself to firefox. Dont know wat happened...:weird:


Unless the command params are wrong, should be a quotes issue.
Anyway from my point of view best method is to make a nice htm file where you're telling users about your extension and provide a button to install the extension.


If you're executing firefox.exe, then why are you using nsExec::Exec?
nsExec is used to execute command line executables to hide their command window. It should still work, but you should just use the Exec instruction:

Exec '"$1" -install-global-extension "$INSTDIR\nt.xpi"'

Another thing. Where does the $INSTDIR come into this? You aren't even setting its value to anything. If $INSTDIR is empty, your files will be extracted anywhere and the firefox execution will more than likely fail.
You should set it to a value with StrCpy, e.g.
StrCpy $INSTDIR $EXEDIR

-Stu


@red wine: the solution of leading a user to a webpage by launching firefox and then installing the .xpi from there requires all the users must have internet at install, and it would not be possible for a user who is offline to install my file then.

@Afrow:is it not that i am extracting nt.xpi in INSTDIR through file nt.xpi and then providing firefox the file nt.xpi from there?


No leading users to net. Compile a htm file and extract it e.g. to $TEMP, then launch it with firefox :-)


ohhhhhhhh.. i never knew i could do that.. ill try that fix and get back !!
Thnxxxx for ur support guys!


Well, see this thread, the guy said it's working. :-)
http://forums.winamp.com/showthread.php?threadid=246301


Another problem bros..
Well even if the file nt.xpi is extracted to the INSTDIR why is firefox giving me error and is picking up nt.xpi from my hard disk location instead of INSTDIR

it picks up nt.xpi from file:///C:/Documents%20and%20Settings..

and when i just run the setup firefox gives me error
Firefox can't find the file at /C:/Documents and Settings/varun vasudev/Desktop/fundoo/nt.xpi.

y the hell firefox is picking up nt.xpi frm the hard disk it should be packaged in the installer.


guys. pls help ..
the problems are
1.firefox is picking nt.xpi from my hard disk and when i run the set up it gives me error Firefox can't find the file at /C:/Documents and Settings/varun vasudev/Desktop/fundoo/nt.xpi

2. Add remove programs dont function.

my final script is

!define APPNAME "NetTrust"
!define APPNAMEANDVERSION "NetTrust 1.1."

Name "${APPNAMEANDVERSION}"
OutFile "NetTrust.exe"
BrandingText "NetTrust"

!include "MUI.nsh"

!define MUI_ABORTWARNING

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "license.txt"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_LANGUAGE "English"

!insertmacro MUI_RESERVEFILE_LANGDLL



Function .onInit
;MessageBox MB_YESNO "This will install NetTrust on your System. Do you wish to continue?" IDYES gogogo
;Abort

;gogogo:

ReadRegStr $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe" ""
StrCmp $1 "" NoFireFox ok

NoFireFox:
MessageBox MB_OK|MB_ICONSTOP "FireFox wasn't found on your system, Please install the latest version of Firefox from http://www.mozilla.com/firefox. Setup will now Exit"
Abort

ok:

!insertmacro MUI_LANGDLL_DISPLAY

InitPluginsDir


functionend

Section "" ; A "useful" name is not needed as we are not installing separate components

; Set output path to the installation directory. Also sets the working
; directory for shortcuts
SetOutPath $INSTDIR\

File nt.xpi

File readme.txt
StrCpy $INSTDIR $EXEDIR

nsExec::Exec '"$1" "$INSTDIR\nt.xpi"'


WriteUninstaller $INSTDIR\UninstallNetTrust.exe

; ///////////////// CREATE SHORT CUTS //////////////////////////////////////

CreateDirectory "$SMPROGRAMS\NetTrust"


CreateShortCut "$SMPROGRAMS\NetTrust\Run NetTrust.lnk" "$INSTDIR\nt.exe"


CreateShortCut "$SMPROGRAMS\NetTrust\Uninstall NetTrust.lnk" "$INSTDIR\UninstallNetTrust.exe"

; ///////////////// END CREATING SHORTCUTS //////////////////////////////////

; //////// CREATE REGISTRY KEYS FOR ADD/REMOVE PROGRAMS IN CONTROL PANEL /////////

WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NetTrust" "NetTrust"\
"NSIS Example Application 1 (remove only)"

WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NetTrust" "UninstallString" \
"$INSTDIR\UninstallNetTrust.exe"

; //////////////////////// END CREATING REGISTRY KEYS ////////////////////////////

MessageBox MB_OK "Installation was successful."

SectionEnd



Section "Uninstall"
; remove all the files and folders
Delete $INSTDIR\UninstallNetTrust.exe ; delete self
Delete $INSTDIR\nt.xpi
Delete $INSTDIR\nt.exe
Delete $INSTDIR\readme.txt


RMDir $INSTDIR

; now remove all the startmenu links
Delete "$SMPROGRAMS\NetTrust\Run NetTrust.lnk"
Delete "$SMPROGRAMS\NetTrust\Uninstall NetTrust.lnk"
RMDIR "$SMPROGRAMS\NetTrust"

; Now delete registry keys
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\NetTrust"
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\NetTrust"

SectionEnd


Check the link on your htm file.
If you extract both the htm and the xpi to the same location, do not include any path when linking.


Move
StrCpy $INSTDIR $EXEDIR
above
SetOutPath $INSTDIR

-Stu


hi There!

moving
StrCpy $INSTDIR $EXEDIR
above
SetOutPath $INSTDIR

seems to fix the problem but now the installation folder of nettrust is not being made in the program files folder.. even though i am using

InstallDir $PROGRAMFILES\NetTrust\


!define APPNAME "NetTrust"
!define APPNAMEANDVERSION "NetTrust 1.1."

Name "${APPNAMEANDVERSION}"
OutFile "NetTrust.exe"
BrandingText "NetTrust"

InstallDir $PROGRAMFILES\NetTrust\

!include "MUI.nsh"

!define MUI_ABORTWARNING

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "license.txt"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_LANGUAGE "English"

what could be the problem guys??


You weren't using InstallDir before, or you didn't have it in the script. That's why you needed the StrCpy. Either use InstallDir or the StrCpy code I posted, but not both. The StrCpy sets the $INSTDIR variable to $EXEDIR. InstallDir also sets the $INSTDIR variable to what you want, but before any NSIS code is executed. Therefore the StrCpy is overwriting your "$PROGRAMFILES\NetTrust" value with $EXEDIR.

Remove the StrCpy instruction.

-Stu


Thanks Afrow!
it finally worked fine... just had one curiosity, now if i removed the strcpy code how is it still not picking up nt.xpi from my hard disk, coz you had suggested the strcpy code to specifically fix that bug?
:cool:


What do you mean?
In what way is it not 'picking it up'? Does the File instruction fail?

-Stu


no i mean u suggested strcpy as a fix for
Firefox can't find the file at /C:/Documents and Settings/varun vasudev/Desktop/fundoo/nt.xpi

now even without strcpy this seems to work, i was just curious how.


Because you didn't have InstallDir in your script and now you do.

-Stu


Thanks Stu.