Backup Firefox/Chrome Bookmarks - VBScript or Kix


I need a script in either vbscript or kix to backup Firefox and Chrome bookmarks.
The script should check for a profile folder for either browser and backup the following to the  to U:\ drive.

The folder I need backed-up for Firefox is:
Firefox - %APPDATA%\Mozilla\Firefox\Profiles\[PROFILE NAME]\bookmarkbackups

The files I need backed-up for Chrome are:
Chrome - %LOCALAPPDATA%\Google\Chrome\User Data\Default\Bookmarks and Bookmarks.bak

If a profile does not exist then it should be skipped. A log file should be created.

I appreciate your help on this.

LVL 22
Ivano ViolaSystem AdministratorAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

Meir RivkinConnect With a Mentor Full stack Software EngineerCommented:
here complete script:
Set FSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")

destination = "U:\"
appdata = objShell.ExpandEnvironmentStrings("%APPDATA%")
localAppData = objShell.ExpandEnvironmentStrings("%LOCALAPPDATA%")

ff_bookmarks = appdata & "\Mozilla\Firefox\Profiles\"
chrome_bookmarks = localAppData & "\Google\Chrome\User Data\Default\Bookmarks"
chrome_bookmarks_bak = localAppData & "\Google\Chrome\User Data\Default\Bookmarks.bak"

For Each Subfolder in FSO.GetFolder(ff_bookmarks).SubFolders
	ff_profile_bookmarks = Subfolder.Path & "\bookmarkbackups"
	if (fso.FolderExists(ff_profile_bookmarks)) then
		fso.CopyFolder ff_profile_bookmarks, destination
		wscript.echo "copy " & ff_profile_bookmarks & " to " & destination
	end if

If (fso.FileExists(chrome_bookmarks_bak)) Then
	fso.CopyFile chrome_bookmarks_bak , destination & "Bookmarks.bak"
	wscript.echo "copy " & chrome_bookmarks & " to " & destination
end if	

If (fso.FileExists(chrome_bookmarks)) Then
	fso.CopyFile chrome_bookmarks , destination & "Bookmarks"
	wscript.echo "copy " & chrome_bookmarks & " to " & destination
end if

wscript.echo "Done."

Open in new window

if u change the destination, make sure to have slash at the end (i.e. "U:\some-folder\")
Meir RivkinFull stack Software EngineerCommented:
All Courses

From novice to tech pro — start learning today.