Jump to content

Recommended Posts

Posted (edited)

Hi guys, needed something to speed up the backup of the firefox profile, so i did this,

works for me just right, and it's here available to anyone who needs it.

Obviously gotta thank to everyone who helped me, and had so much patience to help out. Thumbs up for Melba23!

This works like this: press backup, it searches for the file extensions.ini in a subfolder of all fixed drives PROGS01 INSTALL

If not found, backs it up to 'C:FFProfBackup'

The restore function is similar, searches for the same file in the same manner,

not found, searches for 'C:FFProfBackup', if found uses that, not found any, won't do anything.

Uses a method of deleting the destination dir, and copying the source on it, So use at your risk.

Don't blame me if your pc caught fire, or got infested with cockroaches. hehe

PS: Uses Melba23 UDF RecFileListToArray that you can get

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=ResourcesFox.ico
#AutoIt3Wrapper_Res_Icon_Add=ResourcesFox.ico
#AutoIt3Wrapper_Run_Tidy=n
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Array.au3>
#include <GuiListView.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ListViewConstants.au3>
#include <RecFileListToArray.au3>
Opt("GUIOnEventMode", 1)
Opt("TrayAutoPause", 0)
Opt("TrayIconDebug", 1)

$Form1 = GUICreate("Firefox Profile Backup", 600, 300, 190, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
$Backup = GUICtrlCreateButton("Backup", 10, 265, 75, 25)
GUICtrlSetOnEvent($Backup, "Backup")
$Restore = GUICtrlCreateButton("Restore", 120, 265, 75, 25)
GUICtrlSetOnEvent($Restore, "Restore")
$Exit = GUICtrlCreateButton("Exit", 230, 265, 75, 25)
GUICtrlSetOnEvent($Exit, "Close")

$cListView = GUICtrlCreateListView("Path", 10, 80, 580, 130)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 575)

$Label1 = GUICtrlCreateLabel("Profile Folder", 10, 10, 130, 17)
$Label2 = GUICtrlCreateLabel("Backup/Restore Folder(s) List", 10, 60, 200, 17)
$Label2 = GUICtrlCreateLabel("Backup/Restore Relative Folder", 10, 220, 200, 17)
$Input1 = GUICtrlCreateInput(@AppDataDir & 'MozillaFirefox', 10, 30, 580, 21)
$Input2 = GUICtrlCreateInput('PROGS', 10, 240, 580, 21)
$ProfileDir = GUICtrlRead($Input1)
$DestDir = GUICtrlRead($Input2)
;$DefaultBackup = ('C:FFProfBackup')
$aArray = DriveGetDrive('FIXED')
If @error Then
MsgBox(4096, "DriveGetDrive", "It appears an error occurred.")
Else
For $i = 1 To $aArray[0]
$aList = _RecFileListToArray(StringUpper($aArray[$i]) & $DestDir, "extensions.ini", 1, 1, 0, 2)
If IsArray($aList) Then
For $u = 1 To $aList[0]
GUICtrlCreateListViewItem($aList[$u], $cListView)
Next
EndIf
Next
EndIf

GUISetState(@SW_SHOW)

Func Backup()
$ProfileDir = GUICtrlRead($Input1)
$DestDir = GUICtrlRead($Input2)
If FileExists(@AppDataDir & 'MozillaFirefoxProfilesdefault.defaultextensions.ini') Then
_GUICtrlListView_DeleteAllItems($cListView)
ProgressOn("Progress...", "Working", "")
$aArray = DriveGetDrive('FIXED')
If @error Then
MsgBox(4096, "DriveGetDrive", "It appears an error occurred.")
Else
For $i = 1 To $aArray[0]
$aList = _RecFileListToArray(StringUpper($aArray[$i]) & $DestDir, "extensions.ini", 1, 1, 0, 2)
If IsArray($aList) Then
For $u = 1 To $aList[0]
GUICtrlCreateListViewItem($aList[$u], $cListView)
DirRemove(StringTrimRight($aList[$u], 40), 1)
Sleep(3000)
DirCopy(@AppDataDir & 'MozillaFirefox', StringTrimRight($aList[$u], 40), 1)
If FileExists($aList[$u]) Then
MsgBox(4096, 'Success!', 'Files copied successfully From: ' & $ProfileDir & ' >>> to >>> ' & (StringTrimRight($aList[$u], 40)))
EndIf
ProgressSet(50, "50 %", "Working")
Next
Else
MsgBox(4096, "Info", "No Backup found in subdirectories: " & StringUpper($aArray[$i]) & $DestDir)
;DirCopy($ProfileDir, $DefaultBackup, 1)
DirCopy($ProfileDir, StringUpper($aArray[$i]) & $DestDir, 1)
;MsgBox(4096, "Info", 'Backup done in: ' & $DefaultBackup & ' >>> And >>> ' & StringUpper($aArray[$i]) & $DestDir)
MsgBox(4096, "Info", 'Backup done in: ' & StringUpper($aArray[$i]) & $DestDir)
EndIf
Next
EndIf
ProgressSet(100, "100 %", "Done!")
Sleep(1000)
ProgressOff()
Else
MsgBox(4096, "Info", "No Profile in: " & $ProfileDir)
EndIf
EndFunc ;==>Backup

Func Restore()
$ProfileDir = GUICtrlRead($Input1)
$DestDir = GUICtrlRead($Input2)
_GUICtrlListView_DeleteAllItems($cListView)
ProgressOn("Progress...", "Working", "")
$aArray = DriveGetDrive('FIXED')
If @error Then
MsgBox(4096, "DriveGetDrive", "It appears an error occurred.")
Else
ProgressSet(50, "50 %", "Working")
For $i = 1 To $aArray[0]
$aList = _RecFileListToArray(StringUpper($aArray[$i]) & $DestDir, "extensions.ini", 1, 1, 0, 2)
If IsArray($aList) Then
For $u = 1 To $aList[0]
GUICtrlCreateListViewItem($aList[$u], $cListView)
DirRemove($ProfileDir, 1)
Sleep(2000)
DirCopy(StringTrimRight($aList[$u], 40), $ProfileDir, 1)
ProgressSet(75, "75 %", "Working")
If FileExists(@AppDataDir & 'MozillaFirefoxProfilesdefault.defaultextensions.ini') Then
MsgBox(4096, 'Success!', 'Files copied successfully From: ' & (StringTrimRight($aList[$u], 40)) & ' >>> to >>> ' & $ProfileDir)
Else
MsgBox(4096, "Info", "No Profile in: " & $ProfileDir)
EndIf
Next
Else
MsgBox(4096, "Info", "No Backup found in subdirectories: " & StringUpper($aArray[$i]) & $DestDir)
;If FileExists($DefaultBackup & 'Profilesdefault.defaultextensions.ini') Then
;DirCopy($DefaultBackup, $ProfileDir, 1)
;MsgBox(4096, "Info", 'Backup copied from: ' & $DefaultBackup)
;EndIf
If FileExists(StringUpper($aArray[$i]) & $DestDir & 'Profilesdefault.defaultextensions.ini') Then
DirCopy(StringUpper($aArray[$i]) & $DestDir, $ProfileDir, 1)
MsgBox(4096, "Info", 'Backup copied from: ' & StringUpper($aArray[$i]) & $DestDir)
EndIf
EndIf
Next
EndIf
ProgressSet(100, "100 %", "Done!")
Sleep(1000)
ProgressOff()
EndFunc ;==>Restore

Func Close()
Exit
EndFunc ;==>Close

Do
Sleep(100)
Until $Form1 = 0

Update 1 includes:

1 - input1 is now readable, change path if different

2 - added input2 to set the relative path to save/restore the backup

3 - Removed/commented defaultpath, meaning it no longer saves to C:FFProfBackup, when there's no destination folder set, instead saves to the relative path you wrote.

4 - Included the udf required, icon, and compiled script

Download careca.googlecode.com

post-68092-0-64972400-1352048027_thumb.p

Edited by careca
  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted

There is a few issues...

1) $Input1 is not used, so no mater what i will input to the «Profile Folder», it will always use predefined path (which can be wrong of course).

2) You can use @AppDataDir to get the firefox data files dir.

And also i think you should put all needed files for this project in one archive, so the user can just download and use it :).

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted (edited)

  On 11/3/2012 at 9:28 PM, 'MrCreatoR said:

There is a few issues...

1) $Input1 is not used, so no mater what i will input to the «Profile Folder», it will always use predefined path (which can be wrong of course).

2) You can use @AppDataDir to get the firefox data files dir.

And also i think you should put all needed files for this project in one archive, so the user can just download and use it :).

Hello, thanks for the input, you're correct input1 is not changing the path, it's only for the user to see where the application is trying to get the profile files, %appdata% environment variable is a good idea.

In order to upload, i got to upload to an external server, didn't want to include files i haven't created, but it seems like a more pratical option for the user.

Greetz,

Careca

EDIT: updated 1st post including your sugestion, added more stuff.

Edited by careca
  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...