QGis Portable (Lisboa 1.8)

 

QGis Portable

Out of curiosity, I did a search to see if QGis could be made portable.  The search lead to a OSM related article here. Being a OSM contributor, I wrote G0ldfish offering the new modified files but didn't get a response so I'm posting on my own site.

This is another tiny project that involves creating a few additional files to to make it work.  I don't believe it justifies
creating a dedicated SoureForge repository for the additional 40k of files that are required to make QGis Portable. I used QGis 1.8.0-Lisboa for my portable installation.  The process is pretty straight forward.

Step 1.) Download and install QGis normally with it's setup program.

Step 2.) Copy the whole install root directory to your portable target directory. It does not have to be have to be off the root directory on your portable drive.  Mine, for example, is "D:\Personal\Thumdrive_Backup\PortableApps\QGIS32"

Step 3.) The QGis default install directory name will NOT work because it has spaces.  Rename the copied directory under your portable apps directory to "QGIS32".  You can use a different name (I believe) but make it short and sweet WITHOUT spaces.  Spaces they will break the complex batch scripts included with QGis.

Step 4.) When QGIS installs, the ".qgis" directory under your Windows XP user account in the "Documents and Settings\username" directory is the config directory.  Copy the contents of that directory to a directory called "config" under you portable installation directory.  Mine is "D:\Personal\Thumdrive_Backup\PortableApps\QGIS32\config".  This is important because QGis plugins will NOT work if you don't.

Portable install directory
            |
            -- config (with contents of original .qgis dir)

Step 5.) Now your ready to use the new and modified launch scripts. For convience I have created a nice little archive with everything you need.  If you don't trust my compiled .exe launch files, I have included the AutoIT scripts that you can compile yourself with the free AutoIT Aut2Exe compiler.

Step 6.)You will need to replace the batch files under your new QGis portable directory with the modified ones. My directory is "D:\Personal\Thumdrive_Backup\PortableApps\QGIS32\bin"
 

(Download is at end of document)

The QGis modified batch source files are as follows:

grass64.bat

@echo off

SET OSGEO4W_ROOT=%~dp0
call %OSGEO4W_ROOT%..\bin\o4w_env.bat
call %OSGEO4W_ROOT%..\apps\grass\grass-6.4.3RC2\etc\env.bat
"%GISBASE%"\etc\init.bat %*

qgis.bat

@echo off

SET OSGEO4W_ROOT=%~dp0

call "%OSGEO4W_ROOT%"..\bin\o4w_env.bat
call "%OSGEO4W_ROOT%"..\apps\grass\grass-6.4.3RC2\etc\env.bat
@echo off
path %PATH%;%OSGEO4W_ROOT%..\apps\qgis\bin;%OSGEO4W_ROOT%..\apps\grass\grass-6.4.3RC2\lib

REM start "Quantum GIS" /B "%OSGEO4W_ROOT%"..\apps\qgis\bin\qgis.exe %*
start "Quantum GIS" /B "%OSGEO4W_ROOT%"..\apps\qgis\bin\qgis.exe --configpath "%OSGEO4W_ROOT%"\config %*

qgis-browser.bat

@echo off

SET OSGEO4W_ROOT=%~dp0
call "%OSGEO4W_ROOT%"..\bin\o4w_env.bat
call "%OSGEO4W_ROOT%"..\apps\grass\grass-6.4.3RC2\etc\env.bat
@echo off
path %PATH%;%OSGEO4W_ROOT%..\apps\qgis\bin;%OSGEO4W_ROOT%..\apps\grass\grass-6.4.3RC2\lib
start "Quantum GIS Browser" /B "%OSGEO4W_ROOT%"..\apps\qgis\bin\qbrowser.exe --configpath "%OSGEO4W_ROOT%"\config %*

 

I have created AutoIT scripts for the Portable apps launcher application.  The scripts are made to be compiled into .exes and put in your self created portable apps directory root. Portable apps will pick them up after a rescan.  You then can assign the newly detected QGis launchers to a new category within the Portable Apps Launcher,  mine is GIS.

Do this by bringing up the portable apps menu, find the launcher under "Other", hover-over (highlight), right-click to bring up menu and then select a new or pre-exsisting category.

 

The new QGis AutoIT launch script source files are as follows:

grass.au3

;Simple exe launcher that calls the GRASS64 batch file one directory in.
;Why?....
; Portable apps requires a launcher exe to be one directory above where the batch files are currently located.
; Portable apps does NOT register or use batch files.
; We must specify a "working" directory.
; **Bonus, we can hide the command line window.
; **Bonus, since we are calling the original bat file we get all the above plus the ability to tweak the original batch file by 
;   not including all the original batch file's contents in this script. Less work for later releases.
; AutoIt makes this easy on us.
; Note - Compile with "Compile Script to .exe" program to change icon.
Local $target, $wrkFolder
$target = @ScriptDir & "\bin\grass64.bat"
$wrkFolder = @ScriptDir & "\bin\"
;Debug line below just shows us what our launch string variables look like. 
;To use - Disable (comment out) ShellExecute, Enable (uncomment) MsgBox, compile and run from intended launch directory
;         to make sure you $target and $wrkFolder strings are correct. When done, reverse steps, compile and use.
;MsgBox(0, "AutoIt Var Example", "sDir="& $target & @CRLF & "wDir=" & $wrkFolder & @CRLF & "This is line 3")
ShellExecute ($target,"",$wrkFolder,"",@SW_HIDE)

msys.au3

;Simple exe launcher that calls the MSYS batch file one directory in.
;Why?....
; Portable apps requires a launcher exe to be one directory above where the batch files are currently located.
; Portable apps does NOT register or use batch files.
; We must specify a "working" directory.
; **Bonus, we can hide the command line window.
; **Bonus, since we are calling the original bat file we get all the above plus the ability to tweak the original batch file by 
;   not including all the original batch file's contents in this script. Less work for later releases.
; AutoIt makes this easy on us.
; Note - Compile with "Compile Script to .exe" program to change icon.
Local $target, $wrkFolder
$target = @ScriptDir & "\apps\msys\msys.bat"
$wrkFolder = @ScriptDir & "\apps\msys\"
;Debug line below just shows us what our launch string variables look like. 
;To use - Disable (comment out) ShellExecute, Enable (uncomment) MsgBox, compile and run from intended launch directory
;         to make sure you $target and $wrkFolder strings are correct. When done, reverse steps, compile and use.
;MsgBox(0, "AutoIt Var Example", "sDir="& $target & @CRLF & "wDir=" & $wrkFolder & @CRLF & "This is line 3")
ShellExecute ($target,"",$wrkFolder,"",@SW_HIDE)

OSGeo4W.au3

;Simple exe launcher that calls the OSGeo4W batch file one directory in.
;Why?....
; Portable apps requires a launcher exe to be one directory above where the batch files are currently located.
; Portable apps does NOT register or use batch files.
; We must specify a "working" directory.
; **Bonus, we can hide the command line window.
; **Bonus, since we are calling the original bat file we get all the above plus the ability to tweak the original batch file by 
;   not including all the original batch file's contents in this script. Less work for later releases.
; AutoIt makes this easy on us.
; Note - Compile with "Compile Script to .exe" program to change icon.
Local $target, $wrkFolder
$target = @ScriptDir & "\OSGeo4W.bat"
$wrkFolder = @ScriptDir & ""
;Debug line below just shows us what our launch string variables look like. 
;To use - Disable (comment out) ShellExecute, Enable (uncomment) MsgBox, compile and run from intended launch directory
;         to make sure you $target and $wrkFolder strings are correct. When done, reverse steps, compile and use.
;MsgBox(0, "AutoIt Var Example", "sDir="& $target & @CRLF & "wDir=" & $wrkFolder & @CRLF & "This is line 3")

; DON'T HIDE THIS ONE, IT'S CONSOLE APP!
ShellExecute ($target,"",$wrkFolder)

qgis.au3

;Simple exe launcher that calls the QGIS batch file one directory in.
;Why?....
; Portable apps requires a launcher exe to be one directory above where the batch files are currently located.
; Portable apps does NOT register or use batch files.
; We must specify a "working" directory.
; **Bonus, we can hide the command line window.
; **Bonus, since we are calling the original bat file we get all the above plus the ability to tweak the original batch file by 
;   not including all the original batch file's contents in this script. Less work for later releases.
; AutoIt makes this easy on us.
; Note - Compile with "Compile Script to .exe" program to change icon.
Local $target, $wrkFolder
$target = @ScriptDir & "\bin\qgis.bat"
$wrkFolder = @ScriptDir & "\bin\"
;Debug line below just shows us what our launch string variables look like. 
;To use - Disable (comment out) ShellExecute, Enable (uncomment) MsgBox, compile and run from intended launch directory
;         to make sure you $target and $wrkFolder strings are correct. When done, reverse steps, compile and use.
;MsgBox(0, "AutoIt Var Example", "sDir="& $target & @CRLF & "wDir=" & $wrkFolder & @CRLF & "This is line 3")
ShellExecute ($target,"",$wrkFolder,"",@SW_HIDE)

qgis-browser.au3

;Simple exe launcher that calls the QGIS-BROWSER batch file one directory in.
;Why?....
; Portable apps requires a launcher exe to be one directory above where the batch files are currently located.
; Portable apps does NOT register or use batch files.
; We must specify a "working" directory.
; **Bonus, we can hide the command line window.
; **Bonus, since we are calling the original bat file we get all the above plus the ability to tweak the original batch file by 
;   not including all the original batch file's contents in this script. Less work for later releases.
; AutoIt makes this easy on us.
; Note - Compile with "Compile Script to .exe" program to change icon.
Local $target, $wrkFolder
$target = @ScriptDir & "\bin\qgis-browser.bat"
$wrkFolder = @ScriptDir & "\bin\"
;Debug line below just shows us what our launch string variables look like. 
;To use - Disable (comment out) ShellExecute, Enable (uncomment) MsgBox, compile and run from intended launch directory
;         to make sure you $target and $wrkFolder strings are correct. When done, reverse steps, compile and use.
;MsgBox(0, "AutoIt Var Example", "sDir="& $target & @CRLF & "wDir=" & $wrkFolder & @CRLF & "This is line 3")
ShellExecute ($target,"",$wrkFolder,"",@SW_HIDE)

 

Step 7.) The compiled AutoIT scripts go in your QGis portable root directory. You can now uninstall the original installation. 

Your finished portable QGis directory should look something like this. (Modified files are outlined.)

 

Here is the download complete with compiled exes and icons.

Enjoy your new QGis Portable installation! 

-- Trouble Shooting Time Saver --

If you receive any errors reported by DLLs (ie ssleay)  you most probably have duplicate DLLs in your system's path that are different versions  of the DLLs QGis uses.  You will have to move or delete them.  I had duplicate versions in my Win32 directory which I had to delete before QGis started up.  These errors CAN ALSO popup after a new soft installation that puts duplicate DDLs in your system path.

 

You can post comments here for the time being.

(Note:  If interested, I did a similar project with a Win32 distribution of Subversion called SVN Portable, you can take a whole SVN Server and repository mirrors with you on the go!  Even though install is dead easy, you will still need to know how to push and pull repos with a SVN client)