LiberKeyPortabilizer

Quick navigation

Introduction

Important:
This is a documentation for the Liberkey portabilization engine (LiberKeyPortabilizer) not a tutorial about “how to portabilize an application”.
You should know what is “portabilization” before read this documentation.

About LiberKeyPortabilizer

Quick presentation:
The LiberKeyPortabilizer reads and uses .lpf 1) files (XML format) “on-the-fly” that it receives with a command line.
By this way you can modify the portabilization rules when you want.

General

LiberKeyPortabilizer has as concept a “centralized” portabilization. A single instance of the Portabilizer is monitoring all applications.

Case of elevated rights

However, if you launched applications with elevated rights a dedicated instance of the Portabilizer will be launched too.

Global overview

How to run

You can create a launcher in the language you want. Just call LiberKeyPortabilizer.exe (located in \LiberKeyTools\LiberKeyPortabilizer folder) and send it the command line.

Code:

\LiberKeyTools\LiberKeyPortabilizer\LiberKeyPortabilizer.exe "Path_of_your_lpf" /lkpend

Trick:
Enable file associations, edit file association configuration.
Add a new extension: lpf

Choose LiberKeyPortabilizer.exe in \LiberKeyTools\LiberKeyPortabilizer folder and edit the properties of this extension (Advanced)
Change command line from

"%1"

to

"%1" /lkpend

Select “Open with LiberKey Portabilizer” line and click on By default then apply modifications in file associations main window. You can now launch your application with a double-click on your MyApplicationLauncher.lpf

How to edit

You can edit and create a lpf file with the text editor of your choice. If your text editor supports syntax highlighting, choose XML format.

Trick:
Enable file associations, open file associations configuration and edit the properties of .lpf extension (Advanced) previously created (see How to run)
Add a new action (New..), select Notepad++LKL.exe and change the command line 2) from

"%1"

to

-lxml "%1"

Apply modifications. Your can now quickly edit lpf files with a right click “Open with Notepad++”

Structure

Structure preview

This is the minimal structure. In this case the LiberKeyPortabilizer just launch the executable. No portabilization operations are done.

<LiberKeyAppLauncher version="0.7">
       <AppInfo>
               <Name></Name>
               <LocalExeName></LocalExeName>
               <ExePath></ExePath>
       </AppInfo>
</LiberKeyAppLauncher>

Structure details

All details of the structure are available here.

Examples and source code

You can download an application template here.
Extract it in your “MyApps” folder.

MyApplication.lpf

Code:

MyApplication.lpf
<LiberKeyAppLauncher version="0.7">
	<AppInfo>        
		<Name>MyApplication</Name>
		<LocalExeName>MyApplication.cmd</LocalExeName>
		<ExePath>App\MyApplication\MyApplication.cmd</ExePath>
		<TmpDir>LBK_MyApplication</TmpDir>
		<!-- Uncomment line below to send a command line to MyApplication.cmd -->
		<!-- <AdditionalParameters>--CommandLineSentToMyApplication</AdditionalParameters>-->
	</AppInfo>
</LiberKeyAppLauncher>

MyApplicationLauncher

Two examples of launchers.
MyApplicationLauncher.bat : a simple batch file.

Code:

MyApplicationLauncher.bat
..\..\LiberKeyTools\LiberKeyPortabilizer\LiberKeyPortabilizer.exe %CD%\MyApplicationLauncher.lpf /lkpend

MyApplicationLauncher.nsi : for the creation of a compiled 3) launcher (.exe) in NSIS 4)

Code:

MyApplicationLauncher.nsi
!define NAME "MyApplicationLauncher"
RequestExecutionLevel user
 
Name "${NAME}"
OutFile "${NAME}.exe"
Caption "${NAME}.exe"
;Uncomment line below to define an icon for your launcher
;Icon "${NAME}.ico"
 
CRCCheck On
WindowIcon Off
SilentInstall Silent
AutoCloseWindow True
XPStyle On
 
SetCompress Auto
SetCompressor /SOLID lzma
SetCompressorDictSize 32
SetDatablockOptimize On
 
Var PortabilizerPath
Var PortabilizerApp
Var PortabilizerLK
Var PortabilizerLocal
Var LANCEMENT
Var PARAMTRANS
Var ParamCMD
 
Section "Main"
 
Call GetParameters
Pop $ParamCMD
 
GetFullPathName $PortabilizerLK "$EXEDIR\..\..\LiberKeyTools\LiberKeyPortabilizer\LiberKeyPortabilizer.exe"
GetFullPathName $PortabilizerLocal "$EXEDIR\..\LiberKeyPortabilizer\LiberKeyPortabilizer.exe"
StrCpy $PortabilizerApp "$EXEDIR\LiberKeyPortabilizer\LiberKeyPortabilizer.exe"
StrCpy $PARAMTRANS '$EXEDIR\${NAME}.lpf /lkpend'
 
	IfFileExists $PortabilizerLK FoundPortabilizerLK
 
	IfFileExists $PortabilizerLocal FoundPortabilizerLocal
 
	IfFileExists $PortabilizerApp FoundPortabilizerApp
 
	MessageBox MB_YESNO|MB_ICONQUESTION      `LiberKeyPortabilizer directory not found !
  Do not forget to add it.$\n$\nMore information is available on 
 LiberKey.com$\n$\nDo you want to visit LiberKey.com now ?` IDYES true IDNO false
	true:
	ExecShell "open" "http://www.liberkey.com/"
	Abort
	false:
	Abort
FoundPortabilizerLK:
	StrCpy $PortabilizerPath '$PortabilizerLK'
	Goto TheEnd
 
FoundPortabilizerLocal:
	StrCpy $PortabilizerPath '$PortabilizerLocal'
	Goto TheEnd
 
FoundPortabilizerApp:
	StrCpy $PortabilizerPath '$PortabilizerApp'
 
TheEnd:
	StrCpy $LANCEMENT '$PortabilizerPath $PARAMTRANS $ParamCMD'
	Exec $LANCEMENT
 
SectionEnd
 
Function GetParameters
 
  Push $R0
  Push $R1
  Push $R2
  Push $R3
 
  StrCpy $R2 1
  StrLen $R3 $CMDLINE
 
  ;Check for quote or space
  StrCpy $R0 $CMDLINE $R2
  StrCmp $R0 '"' 0 +3
    StrCpy $R1 '"'
    Goto loop
  StrCpy $R1 " "
 
  loop:
    IntOp $R2 $R2 + 1
    StrCpy $R0 $CMDLINE 1 $R2
    StrCmp $R0 $R1 get
    StrCmp $R2 $R3 get
    Goto loop
 
  get:
    IntOp $R2 $R2 + 1
    StrCpy $R0 $CMDLINE 1 $R2
    StrCmp $R0 " " get
    StrCpy $R0 $CMDLINE "" $R2
 
  Pop $R3
  Pop $R2
  Pop $R1
  Exch $R0
 
FunctionEnd