Skip to content
⌘ NSIS Forum Archive

Installer for Firefox Toolbar

39 posts

varun#

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.
varun#
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.
RobGrant#
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.
varun#
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.
RobGrant#
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 🙂
varun#
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
JasonFriday13#
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"'
varun#
<<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?
JasonFriday13#
True. Sorry, it's just that I always use $0 as my first variable. It should be $1 in your case.
Red Wine#
Does this "nt.xpi" exist on target, or you're going to extract it?
I think a path to the file is missing.
varun#
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.
Red Wine#
Yes,
SetOutPath $INSTDIR
File .....
File .....
File nt.xpi
nsExec::Exec '"$1" -install-global-extension "$INSTDIR\nt.xpi"'
varun#
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
Afrow UK#
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
varun#
😳 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...🤪
Red Wine#
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.
Afrow UK#
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
varun#
@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?
Red Wine#
No leading users to net. Compile a htm file and extract it e.g. to $TEMP, then launch it with firefox :-)
varun#
ohhhhhhhh.. i never knew i could do that.. ill try that fix and get back !!
Thnxxxx for ur support guys!
Red Wine#
Well, see this thread, the guy said it's working. :-)
Are you a developer who uses NSIS to distribute your application? Are you a Winamp plug-in developer who wants to use NSIS to distribute your plug-in? Have suggestions for other people like you? This is the place.
varun#
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.
varun#
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