Recent answers to silently merge bookmarks with deployed FireFoxhttps://support.mozilla.org/en-US/questions/9379562013-01-13T09:46:19-08:00Part 2
If StringInStr($rdfilename, $mff_bm) >0 And WinExists ("Import Bookmarks File")=1 The2013-01-13T09:46:19-08:00standovhttps://support.mozilla.org/en-US/questions/937956#answer-397270<p>Part 2
</p><p><br>
</p>
<pre> If StringInStr($rdfilename, $mff_bm) &gt;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." &amp; @CRLF &amp; @CRLF &amp; " 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." &amp; @CRLF &amp; @CRLF &amp; "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." &amp; @CRLF &amp; @CRLF &amp; "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 &amp; "\Mozilla\Firefox\Profiles\", "*", 2)
If @error &gt;0 Then
_log ("error in retrieving profiles directory")
MsgBox (0, "Profile files not copied", "Profile files not copied for corp security changes" &amp; @CRLF &amp; @CRLF &amp; " Please report this to IT support")
Exit
EndIf
for $i = 1 to $ARfolders[0]
;FileCopy($SoftLib &amp; "\Mozilla_firefox\core\defaults\profile", @AppDataDir &amp; "\Mozilla\Firefox\Profiles\" &amp; $ARfolders[$i], 1)
DirCopy($SoftLib &amp; "\Mozilla_firefox\core\defaults\profile", @AppDataDir &amp; "\Mozilla\Firefox\Profiles\" &amp; $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" &amp; " http://corpintranet/");if firefox is not running, run it
_log ("end script and FF should be running, not that it matters")
EndFunc</pre>ok guys,
here is the script I wrote (I called the exe file FirefoxBM.exe)- I hope it helps out. Sor2013-01-13T09:45:40-08:00standovhttps://support.mozilla.org/en-US/questions/937956#answer-397269<p>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.
</p><p>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.
</p><p>the hashes changed to numbers on this page, so you have to remove the dash infront to convert back to autoit code.
</p><p>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.
</p><p>good luck and I hope you get it to work
</p>
<pre>-#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 &lt;File.au3&gt;
-#include &lt;Array.au3&gt;
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 &gt; RegRead ("HKCU\Software\corp\Software\Mozilla", "ImportedBookmarks") And $SoftLib &lt;&gt; "" 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 &amp; '\logs\Mozilla_Firefox_bookmarks.txt', @MDAY&amp;"\"&amp;@MON&amp;"\"&amp;@YEAR &amp;"-"&amp; @HOUR&amp;":"&amp;@MIN&amp;"."&amp;@SEC &amp; " - &gt; " &amp; $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." &amp; @CRLF &amp; "Please wait while the corporate bookmarks are being updated." &amp; _
@CRLF &amp; "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." &amp; @CRLF &amp; @CRLF &amp; " 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." &amp; @CRLF &amp; @CRLF &amp; " 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." &amp; @CRLF &amp; @CRLF &amp; " 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." &amp; @CRLF &amp; @CRLF &amp; " 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." &amp; @CRLF &amp; @CRLF &amp; " 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." &amp; @CRLF &amp; @CRLF &amp; " Please report this to IT support")
Exit
EndIf
ControlSetText ("Import Bookmarks File", "", "[CLASS:Edit; INSTANCE:1]", $SoftLib &amp; $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." &amp; @CRLF &amp; @CRLF &amp; " 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." &amp; @CRLF &amp; @CRLF &amp; " Please report this to IT support")
Exit
endif</pre>right - this looks like this can't be done using a Mozilla function. I had to write a script to (on2012-10-11T15:42:10-07:00standovhttps://support.mozilla.org/en-US/questions/937956#answer-373949<p>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.
</p><p>if you message me I might be able to guide you in the right direction
</p>is there anybody that can answer this question? Is there a way of adding/merging bookmarks into fir2012-10-02T12:31:10-07:00standovhttps://support.mozilla.org/en-US/questions/937956#answer-372049<p>is there anybody that can answer this question? Is there a way of adding/merging bookmarks into firefox under an unattended corporate environment?
</p>Right, with some testing, i have discovered - using the "browser.places.importbookmarkshtml" will im2012-09-25T15:51:40-07:00standovhttps://support.mozilla.org/en-US/questions/937956#answer-370691<p>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?
</p>