K-Meleon

KMeleonWiki > Resources > MacroLibrary > KmmResProfile

Submitted by: JamesD



Notes:

ResProfile.kmm will allow a copy of the files and folders in a user’s K-Meleon profile folder to be written to a location of the user’s choice.

The menu item for ResProfile is found in the Tools menu.

The copy activity occures after K-Meleon is stopped. This is because K-Meleon, while running, has write permission to some profile files. The copy activity is delayed two seconds after the OnQuit event in K-Meleon to give time for any writes to the files to finish. The user should not restart K-Meleon until there has been time for the script file to complete.

There is also a ProfileBackup installable extention by Guenter at Alain Aupeix’s site. http://pagesperso-orange.fr/jujuland46/JujuLand/KMES/KMES-Download.html#down_extensions




Open your User Macro Folder (Edit > Configuration > User-Defined Macros) or your Macro Folder (Edit > Configuration > Macros) and create the following text file(s):

ResProfile.kmm

#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- ResProfile.kmm
# ---------- K-Meleon Macro Language make a reserve copy of your profile ---------------
#
# Dependencies                : main.kmm
# Resources                                : ResProfile.js
# Preferences                        : -
# Version                                        : 0.8.5   2007-12-06
# --------------------------------------------------------------------------------

ResProfile_RunCode {
        $_ResProfile_Cur_Profile_Path = getfolder(ProfileFolder);
        $_ResProfile_Reserve_Path = promptforfolder( "Select a folder for your Reserve Profile.\nIt is best to make a separate folder.\nThe folder does not need to be within K-Meleon." , getfolder(RootFolder) ); 
        $_ResProfile_Reserve_Path ==""? &_ResProfile_Cancel : &_ResProfile_ValidateNotSameFolder;
        }

#  PRIVATE  --------------

#  set global variables
$_ResProfile_Staged_Flag = false;
$_ResProfile_Cur_Profile_Path = "dummy" ;
$_ResProfile_Reserve_Path = "dummy" ;

_ResProfile_Cancel {
        $ResProfile_Button=confirm("Did you mean to cancel?","Affirm cancel" ,YESNO,QUESTION);
        $ResProfile_Button == "YES" ? 0 : &_ResProfile_RunCode ;
        }        
        
_ResProfile_ValidateNotSameFolder {
        $_ResProfile_Cur_Profile_Path == $_ResProfile_Reserve_Path ? &_ResProfile_ReDo : &_ResProfile_Staged ;                
        }        

_ResProfile_ReDo {
        alert("Target of copy should not be\n\nthe profile folder.","Copy to itself",EXCLAIM);
        &_ResProfile_RunCode ;
        }        
                
_ResProfile_Staged {
        $_ResProfile_Staged_Flag = true ;
        }
        
_ResProfile_ExitRun {
        $_ResProfile_Staged_Flag == true ? exec("wscript.exe \"".$_ResProfile_Path."\" \"".$_ResProfile_Cur_Profile_Path."\" \"".$_ResProfile_Reserve_Path."\"") : 0 ;
        }

_ResProfile_BuildMenu{
        setmenu("&Tools",macro,"Reserve Profile",ResProfile_RunCode,Misc);
        }

_ResProfile_GetPath{
### ResProfile.js is supposed to be located in the same folder as ResProfile.kmm (this file).
### If it isn't, Windows Script Host will notify the user.
### Double underscore makes variable local only.
$__Data=readfile(getfolder(MacroFolder)."\\ResProfile.kmm");
$_ResProfile_Path=getfolder($__Data==""?UserMacroFolder:MacroFolder)."\\ResProfile.js";
}

$OnQuit=$OnQuit."_ResProfile_ExitRun;";
$OnStartup=$OnStartup."_ResProfile_GetPath;";
$OnInit=$OnInit."_ResProfile_BuildMenu;";
$macroModules=$macroModules."ResProfile;";


ResProfile.js

/* ResProfile.js by JamesD, version  0.9   2007-12-15

   This script is a helper application for the K-Meleon Macro Module ResProfile.kmm that
   enables you to make a reserve ( backup ) copy of your profile  [<unique name>.slt].
   
   Windows Script Host 2.0 (or better) required!
   
   WSH is part of Microsoft Internet Explorer 5.0 and newer. Latest version of WSH is
   available at http://msdn.microsoft.com/scripting/
*/

var c, r, i, RegF, RegFTwo ;
var overwrite = 1 ;
var Current_Profile_Path  = WScript.Arguments(0);
var Reserve_Profile_Path  = WScript.Arguments(1);
var objfso = new ActiveXObject("Scripting.FileSystemObject");
WScript.Sleep( 2000) ;
if (objfso.FolderExists(Current_Profile_Path))  { c = "exists" ; }
if (objfso.FolderExists(Reserve_Profile_Path))  { r = "exists" ;  }
if (c == "exists" && r == "exists")  {objfso.copyfolder(Current_Profile_Path, Reserve_Profile_Path, overwrite); }
K-Meleon

(c) 2000-2010 kmeleonbrowser.org. All rights reserved.
design by splif.