Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

silently merge bookmarks with deployed FireFox

  • 5 replies
  • 1 has this problem
  • 5 views
  • Last reply by standov

more options

Hi all, I am trying to create a deployment for FireFox on our corporate network (still running XP). The problem I have, there are some/lots of people who already have a manually installed version of FF installed and I need to create a deployment that "takes over" the current install, including all settings for the %userprofile%\Application Data\Mozilla\Firefox\Profiles\{FF.profile}. Located in this path is the places.sqlite file for bookmarks. If I was to create a complete copy over/install of %ProgramFiles%\Mozilla Firefox and the above profile location, it would give a nice clean SOE install, but would over write currently bookmarked URL's. Part of the deployment, I have been asked to provide 6 URL's in the bookmarks.

Here comes the tricky question (Google has failed me on this one), how can I silently inject 6 URL's (preferably at the top of the bookmarks) into the deployment of FF, without wiping the current bookmarks owned by the user, and still "own" the install completely?

is there a way to list them in mozilla.cfg, prefs.js or something for injection to the deployment?

Thanks in advance for any information.

Edit: even if I can run the import wizard silently, that would be ok as well.

Hi all, I am trying to create a deployment for FireFox on our corporate network (still running XP). The problem I have, there are some/lots of people who already have a manually installed version of FF installed and I need to create a deployment that "takes over" the current install, including all settings for the %userprofile%\Application Data\Mozilla\Firefox\Profiles\{FF.profile}. Located in this path is the places.sqlite file for bookmarks. If I was to create a complete copy over/install of %ProgramFiles%\Mozilla Firefox and the above profile location, it would give a nice clean SOE install, but would over write currently bookmarked URL's. Part of the deployment, I have been asked to provide 6 URL's in the bookmarks. Here comes the tricky question (Google has failed me on this one), how can I silently inject 6 URL's (preferably at the top of the bookmarks) into the deployment of FF, without wiping the current bookmarks owned by the user, and still "own" the install completely? is there a way to list them in mozilla.cfg, prefs.js or something for injection to the deployment? Thanks in advance for any information. Edit: even if I can run the import wizard silently, that would be ok as well.

Modified by standov

Chosen solution

right - this looks like this can't be done using a Mozilla function. I had to write a script to (on screen) push buttons, to open library, import bookmarks file type the server (env var) and file location. I had to write it in Autoit 3.3.8.1. I am not going to post it here, because of our work policy, it was developed in works time, it then belongs to work. The script is near on 180 lines, took me about a week to write (not a very experienced scripter) with full error checking and window existence checking. however with the way some of the FF windows are written, there is no control items to identify and use some windows and buttons.

if you message me I might be able to guide you in the right direction

Read this answer in context 👍 0

All Replies (5)

more options

Right, with some testing, i have discovered - using the "browser.places.importbookmarkshtml" will import the bookmarks.html, but wipes the users current bookmarks in the places file. Doing a "show all bookmarks" and Import html will not wipe the users bookmarks. Is there a way for the "browser.places.importbookmarkshtml" to not wipe the users data?

more options

is there anybody that can answer this question? Is there a way of adding/merging bookmarks into firefox under an unattended corporate environment?

more options

Chosen Solution

right - this looks like this can't be done using a Mozilla function. I had to write a script to (on screen) push buttons, to open library, import bookmarks file type the server (env var) and file location. I had to write it in Autoit 3.3.8.1. I am not going to post it here, because of our work policy, it was developed in works time, it then belongs to work. The script is near on 180 lines, took me about a week to write (not a very experienced scripter) with full error checking and window existence checking. however with the way some of the FF windows are written, there is no control items to identify and use some windows and buttons.

if you message me I might be able to guide you in the right direction

more options

ok guys, here is the script I wrote (I called the exe file FirefoxBM.exe)- I hope it helps out. Sorry for the non-streamlined scripting, I am only a novice. I have included as much commenting as I thought so you know what I am doing, and there is backup/fallback options in here as well just in case it fails in anyway. I don't think this is my final version, I could not find a later version date, you might need to modify to suit your needs.

If you use this code in any way, please respect my work and leave my details in the release info at the top, and add your modify details underneath, thanks.

the hashes changed to numbers on this page, so you have to remove the dash infront to convert back to autoit code.

The Bookmarks.html file I created had the corp bookmarks in a folder called "- Corp -". The hyphen and space is above the the alphabet on the Ascii table so most of the time it should display on the top of the bookmarks the users have after being sorted.

good luck and I hope you get it to work

-#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
-#AutoIt3Wrapper_Icon=N:\SoftLib\Mozilla_firefox\28.ico
-#AutoIt3Wrapper_Outfile=..\..\Apps\SoftLib\Mozilla_firefox\FirefoxBM.exe
-#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
-#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
-#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

; FirefoxBM: additions and removals ----------------------------------------------------------------------------------------------------------------------------
;  Release  Autoit version  Author   Details
; 12/10/2012 - v3.3.8.1   lrbreez  - original script written to import bookmarks into FF
;
; End additions and removals

-#include <File.au3>
-#include <Array.au3>

opt("wintitlematchmode",2)
opt("MouseCoordMode", 1); absolute screen coordinates

Global $SoftLib = EnvGet("SoftLib"); reads for SoftLib (software library) in reg - this varibale determines if the workstation is logged on to the network. EnvGet("SoftLib")
Global $importdate = "201211"; ---------date of last imported bookmarks.html, if there is a new version of bookmarks.html, increment this value to the current date--------
Global $logging = True
Global $mff_bm = ("\Mozilla_firefox\bookmarks.html")
Global $filestring

AdlibRegister ("kill_proxy_auth") ;register kill the proxy auth popup


_check()

Func _check()
 if $importdate > RegRead ("HKCU\Software\corp\Software\Mozilla", "ImportedBookmarks") And $SoftLib <> ""  Then; checks reg for current bookmarks and checking for SoftLib var; if computer is logged in before running script
  Call ("_insertbookmarks")
 Else
  If ProcessExists("Firefox.exe") = 0 then
   Run("C:\Program Files\Mozilla Firefox\firefox.exe");if firefox is not running, run it
  Else
   Run("C:\Program Files\Mozilla Firefox\firefox.exe -new-window"); or if this being run and the above checks don't match or firefox is running and the bookmarks are up to date, run firefox in a new window
  EndIf
 EndIf
EndFunc

Func _log($message)
 If $logging Then
  FileWriteLine (@WindowsDir & '\logs\Mozilla_Firefox_bookmarks.txt', @MDAY&"\"&@MON&"\"&@YEAR &"-"& @HOUR&":"&@MIN&"."&@SEC & " - > " & $message)
 EndIf
EndFunc

Func kill_proxy_auth() ;function for adlib to kill proxy auth popup, as this will cause the script to stop if the proxy is called
  If WinExists ("Authentication Required") Then
   WinKill ("Authentication Required")
   _log ("killed proxy request")
  EndIf
EndFunc

Func _InsertBookmarks()
 WinSetState("Novell-delivered Applications", "", @SW_MINIMIZE)
 Dim $result; var for checking on status of window being called; will store file handle of a window or the error code of window not found
BlockInput(1); block mouse and keyboard input
mousemove(1, 1, 0); move the mouse to the top left of screen to make sure current mouse location does not interfere with on screen commands
SplashTextOn("Firefox first time run", "Firefox requires an update to its bookmarks." & @CRLF & "Please wait while the corporate bookmarks are being updated." & _
   @CRLF & "During this time, mouse and keyboard will not function",500,70,Default,20,16+32)
   _log ("splash text")
 If ProcessExists("Firefox.exe") = 0 then
  run ("C:\Program Files\Mozilla Firefox\firefox.exe")
  _log("run firefox"); run firefox if not running
 EndIf
 $result = WinWait ("Mozilla Firefox", "", 30)
  If $result = 0 Then; this will check for a running firefox process, if it won't activate, kill proccess and restart
   ProcessClose ("firefox.exe")
   Sleep(1000)
   Run ("C:\Program Files\Mozilla Firefox\firefox.exe")
   _log ("Firefox process did not respond in 30 seconds, process killed and restarted")
   $result = WinWait ("Mozilla Firefox", "", 30)
   If $result = 0 Then
    _log("Firefox did not run successfully - closing process")
    BlockInput(0)
    Exit
   EndIf
  EndIf
 WinActivate ("Mozilla Firefox")
 WinSetState ("Mozilla Firefox", "", @SW_MAXIMIZE); maximize firefox if currently running but minimized
 $result = WinWaitActive ("Mozilla Firefox", "", 10)
 if $result = 0 Then
  WinMinimizeAll()
  WinSetState ("Mozilla Firefox", "", @SW_MAXIMIZE); maximize firefox if currently running but minimized
  WinActivate ("Mozilla Firefox")
  if WinWaitActive ("Mozilla Firefox", "", 10) =  0 then
   _log("Firefox did not become the active window in time - closing process")
   BlockInput(0)
   SplashOff()
   MsgBox(48, "Firefox has failed", "Firefox has not become the active window in time." & @CRLF & @CRLF & "          Please report this to IT support")
   Exit
  EndIf
 EndIf
 Sleep(500)
 Send ("{ctrldown}{shiftdown}B{ctrlup}{shiftup}"); calls for the bookmarks library
 $result = WinWait ("Library", "", 10)
  If $result = 0 then
   Send("!b{enter}"); if the library window did not call after the winwait, this sends the alturnate key commands
   Sleep(200)
   _log ("process could not open Library via Ctrl+Shift+B - ran fall back")
   $result = WinWait ("Library", "", 10)
    If $result = 0 then
     _log ("Bookmarks library failed to open")
     BlockInput(0)
     SplashOff()
     MsgBox(48, "Bookmarks library failed to open", "Bookmarks library window has not opened or responded in time." & @CRLF & @CRLF & "             Please report this to IT support")
     Exit
    EndIf
  EndIf
 WinActivate ("Library")
 WinMove ("Library", "", 400, 130); moves the library window below the splash text, just incase the below mouse commands are needed.
 if WinWaitActive ("Library", "", 10) = 0 Then
  _log ("Library failed to be active window")
  BlockInput(0)
  SplashOff()
  MsgBox(48, "Library window failed be active", "Library window has not become the active window in time." & @CRLF & @CRLF & "             Please report this to IT support")
  Exit
 EndIf
 _log ("Library opened")
 Send ("!{i 2}"); sends Alt i and i to activate import bookmark dialogue
 $result = WinWait ("Import Bookmarks File", "", 10)
  If $result = 0 then
   opt("MouseCoordMode", 0);sets mouse move relative to window
   WinActivate ("Library")
   if WinWaitActive("Library","",10) =0 then
    _log ("Library failed to be active window for opening import bookmark dialogue")
    BlockInput(0)
    SplashOff()
    MsgBox(48, "Library window failed be active", "Library window has not become the active window in time." & @CRLF & @CRLF & "             Please report this to IT support")
    Exit
   EndIf
   Mouseclick("primary", 260, 45, 1, 0); mouse click over import bookmarks
   Send("i"); sends i to complete library window request, so screen size or font size won't affect this script too much
   opt("MouseCoordMode", 1); sets mouse mode back to relative screen
   Sleep(200)
   _log ("Import bookmarks did not open with Alt+i command, ran fall back command")
   $result = WinWait ("Import Bookmarks File", "", 10)
   If $result = 0 Then
    _log ("failed to open Library window")
    BlockInput(0)
    SplashOff()
    MsgBox(48, "Library window failed to open", "Library window has not opened or responded in time." & @CRLF & @CRLF & "             Please report this to IT support")
    Exit
   EndIf
  EndIf
 ;_log ("Import Bookmarks dialogue opened")
 WinActivate ("Import Bookmarks File")
 if WinWaitActive ("Import Bookmarks File", "", 10)=0 then
 EndIf
 mousemove(1, 1, 0); moves mouse back to corner (just in case)
 if WinExists ("Import Bookmarks File") = 1 Then
  _log ("Importbookmarks opened")
  Else
   _log ("Importbookmarks failed to open")
   SplashOff()
   BlockInput(0)
   MsgBox(48, "Import Bookmarks failed", "Import Bookmarks File window has not opened or responded in time." & @CRLF & @CRLF & "             Please report this to IT support")
   Exit
 EndIf
 ControlSetText ("Import Bookmarks File", "", "[CLASS:Edit; INSTANCE:1]",  $SoftLib & $mff_bm); sends URL to 'File name' in import bookmarks dialogue
 Local $rdfilename = ControlGetText ("Import Bookmarks File", "", "[ID:1148]"); reads file name just filled out in 'inport bookmarks file' and sends to var $rdfilename
 If @error = 1 Then; check for failure of sending URL to 'file name' input
  _log ("failed to read the SoftLib, mozilla firefox, bookmarks input in Import Bookmarks File, File Name")
  SplashOff()
  BlockInput(0)
  MsgBox (48,"Failed to Read bookmarks","The Import of Corporate Bookmarks has failed." & @CRLF & @CRLF & "         Please report this to IT support")
 Else
  if WinWaitActive ("Import Bookmarks File", "", 10) = 0 then
   _log ("Importbookmarks failed to open")
   SplashOff()
   BlockInput(0)
   MsgBox(48, "Import Bookmarks failed", "Import Bookmarks File window has not opened or responded in time." & @CRLF & @CRLF & "             Please report this to IT support")
   Exit
  endif

Modified by cor-el

more options

Part 2


  If StringInStr($rdfilename, $mff_bm) >0  And WinExists ("Import Bookmarks File")=1 Then ;if the 'SoftLib\' to bookmarks is correct and 'Import Bookmarks File' dialouge is open
   RegWrite("HKCU\Software\corp\Software\Mozilla", "ImportedBookmarks", "REG_SZ", $importdate); should write to reg if everything is correct from 'SoftLib\'
   ControlClick ("Import Bookmarks File", "", "[CLASS:Button; INSTANCE:2]", "primary", 1, 30, 11); performs control click on ok button
   _log ("location of bookmarks.html added and control clicked Ok")
  Else
   _log ("failed to either read 'File name' correctly or 'Import Bookmarks File' dialogue has not responded")
   BlockInput(0)
   MsgBox (48,"Failed to Read bookmarks","The Import of Corporate Bookmarks has failed." & @CRLF & @CRLF & "         Please report this to IT support")
   Exit
  EndIf
 EndIf
 sleep(300)
 if WinWait ("Library", "", 10) = 0 then
  _log ("Library failed to wait")
  SplashOff()
  BlockInput(0)
  MsgBox(48, "Easter Egg", "The Library has not waited." & @CRLF & @CRLF & "Please report this to IT support")
  Exit
 endif
 WinActivate ("Library")
 if WinWaitActive ("Library", "", 10) =0 Then
  _log ("Library failed to become active after bookmarks")
  SplashOff()
  BlockInput(0)
  MsgBox(48, "Library not active", "The Library has not become the active window." & @CRLF & @CRLF & "Please report this to IT support")
  Exit
 endif
 Send ("b{APPSKEY}"); sends keystrokes to order personal bookmarks by name so -corp- bookmarks are located near the top
 sleep(500)
 send ("r"); part two of the ordering of bookmarks, presses 'r' on apps menu for sort
 sleep(300)
 send ("!{F4}"); close the Library
 _log ("sent alt F4 to close library")
BlockInput(0)
_replace_profile_files()
SplashOff()
_log ("splash text off")
EndFunc

func _replace_profile_files()
 If ProcessExists("Firefox.exe") then
 WinClose ("Mozilla Firefox") ; have to restart the FF GUI to impliment the GUI changes
 _log ("closed FF for GUI changes")
  If WinExists ("Confirm close", "") =1 Then
   Send ("{enter}")
   _log ("closed opened tabs")
  EndIf
 EndIf
 WinSetState("Novell-delivered Applications", "", @SW_RESTORE)

 Local $ARfolders=_FileListToArray(@AppDataDir & "\Mozilla\Firefox\Profiles\", "*", 2)
If @error >0 Then
 _log ("error in retrieving profiles directory")
 MsgBox (0, "Profile files not copied", "Profile files not copied for corp security changes" & @CRLF & @CRLF & "      Please report this to IT support")
 Exit
EndIf

for $i = 1 to $ARfolders[0]
 ;FileCopy($SoftLib & "\Mozilla_firefox\core\defaults\profile", @AppDataDir & "\Mozilla\Firefox\Profiles\" & $ARfolders[$i], 1)
 DirCopy($SoftLib & "\Mozilla_firefox\core\defaults\profile", @AppDataDir & "\Mozilla\Firefox\Profiles\" & $ARfolders[$i], 1) ;copies over changed files for GUI mod
Next

$result = ProcessWaitClose("firefox.exe", 20)
 If $result = 0 then WinKill ("[class:MozillaWindowClass]", "")

Sleep(300)
Run("C:\Program Files\Mozilla Firefox\firefox.exe" & " http://corpintranet/");if firefox is not running, run it
_log ("end script and FF should be running, not that it matters")
EndFunc

Modified by cor-el