This template should be suitable for most applications to make them portable.
Download it here (latest version 1.4.2):
http://www.loncarek.de/downloads/ApplicationPortableTemplate.zip
It allows saving a lot settings (one or all of them at once):
- One or more registry keys
- One or more settings directories
- One or more settings files
The source contains a lot comments, documenting what I did and why (for those who want to learn).
You could do some additional adjustments in the functions "Init" before calling the application and "Cleanup" after the application closed. I left them empty but prepared for very special customizations.
I took the main idea from the Quickport NSIS template developed by Deuce but rewrote it completely (and added some stuff)
This template has no specific license. Therefore I left the commented license section empty.
Everyone could use this template for creating portable applications out of standard applications (commercial or not). If you make a commercial application portable beware of the respective license terms. Nevertheless it would be nice to share the launcher application.
Just for fun (and testing) I created a NSIS version of a launcher for Inkscape. It works nicely.
Enjoy it and have fun with it.
I haven't included any handling of ini-files or some other directory structure as John usually does in his launchers. If you think it would be a good idea to have, please tell me and I'll add it.
Comments welcome.
In order to compile this script with NSIS you need the following Plugins:
- NewAdvSplash
- Registry
- FindProc
NEW with version 1.1:
INI files and some default directory structures are supported now.
NEW with version 1.2:
added sleep time when deleting registry keys
adopted new directory structure as recently used by John (AppPortable instead of PortableApp)
NEW with version 1.3:
fixed a bug
NEW with version 1.4:
added handling for second launch
some bugfixes
Last tested with NSIS 2.24
I want that Inkscape.
Tutorial or Download?
----
R McCue
"If you're not part of the solution, you're part of the precipitate."
The following is a short tutorial for PortableInkscape as I do not have enough webspace to host it completely. BTW: consider it as beta.
OK, use the above template replace the empty constants with the stuff below:
This has no splashscreen integrated. If you want one create an image and place it in the SPLASHIMAGE constant. Also teh default NSIS application icon is used.
Then do a local install or get the .ZIP archive of inkscape (if there is any) to get the inkscape files.
Create the following directory structure:
The following files can be EXE-compressed (I used WinUPack):
inkscape.exe
inkview.exe
freetype6.dll
intl.dll
jpeg62.dll
msvcr70.dll
popt1.dll
xmlparse.dll
zlib1.dll
libpng13.dll
libgtk-win32-2.0-0.dll
libgdk-win32-2.0-0.dll
libxml2.dll
libtiff3.dll
libpangowin32-1.0-0.dll
Hope this helps... (no warranty for nothing)
BTW: I decided to integrate the handling of INI-files into the template also some additional checking of existing directories and creation on demand. I'll release that in a future version.
I used this to make Portable Robolab, which stores settings to My Documents\ROBOLAB Data. When the program is closed it deletes the contents of the folder, but not the folder itself. It would be great if it could do this. Thanks.
Before I saw Portable Application using NSIS scripts, I used AutoIt3 scripts to run applications, for example, import registry, copy configuration files, run exe, exit exe, export registry. The script also could be compiled and compressed to exe files.
but, NSIS seems better. For example, it seems to be able to make the executables run with configuration files in the same working folder. So, the first question is that how do NSIS scripts achieve that?
NSIS scripts seem more complicated than AutoIt3 scripts. Although I already downloaded your template, NSIS, and read other templates for the portable applications here, I am still not able to pick up quickly. So, I have more questions. Thanks for being patient!
the second question is, some registry files contain path infomation. When using a USB drive, the drive label is often changing, for example, e: or f: or h:. So, could and how do NSIS scripts change path info in registry file according to the current drive labe of the USB drive?
the third question is when the program exits, could and how do NSIS scripts backup/remove the imported registry info and save the configuration files?
The last one, I have prepared a program with the following structure as above:
PortableABCDE (put my ABCDE.exe in here)
+-App
| +-ABCDE (copy the whole local program in here)
+-Data
+-Registry
+-Settings
+-Other
+-PortableInkscapeSource
How could I make changes in your great template? Only in the define section?
Thanks for reading!
Been out there for a while... thought you knew. In English, not French. (I just tried it.)
Portable Inkscape
~Lurk~ Email
~Lurk~
as I said I just did it for testing purposes. And if I don't mix things up with that version AutoIt3 was used for the launcher.
I dont like AutoIt.
Email me and I'll host the tutorial at http://rmccue.stsolutions.us/
----
R McCue
"If you're not part of the solution, you're part of the precipitate."
see at the top...
If you don't mind, I would like the template to work with the Registry Rapper format. thanks
Sorry I do not see the difference in format. Please explain.
It would be nice if you bundled PortableNSIS and a sample Template script to compare with. Thanks for making the template!
see: http://www.portasoft.org/e107/page.php?13
So I don't really see the need for integrating Portable NSIS
Here is an example for inkscape:
http://www.loncarek.de/downloads/InkscapePortableSource.zip
copy all files and directories of your local inkscape installation (or the files out of the distributables, could be found e.g. here: http://sourceforge.net/project/showfiles.php?group_id=93438&package_id=9... ) into the directory PortableInkscape\App\inkscape
Released version 1.1.1 (small bugfix)
Released new version to adopt the new directory structure introduced by John
Would it be possible to write a GUI for this? Thanks.
NSIS just provides a command line compiler and an interface for that compiler. You can use external editors, however, like PSPad (it's already portable) to write scripts for it. Be sure to Website] [Projects] [Blog]
Thanks for the template, but I have a question: how to add a reg key to it?
I stored the required registry keys in a .reg file, but the readme says,
'!define REGKEYS "" ; insert regkeys to use separated by "||"'
Could someone tell me how to do that exactly (via an example)?
Thanks in advance,
tpr
"HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip||HKEY_LOCAL_MACHINE\SOFTWARE\LimeWire" etc
Get it? (I think)
----
R McCue
PortaBlog Home and My Website
PortaBlog is now officially out of beta!
"If you're not part of the solution, you're part of the precipitate."
I like the fact that it passes the command line switches to the app, been using Registry Rapper until now but it doesnt have this feature.
Oh and im wondering if does it support registry entries in different locations? ex HKLM/software/myapp||HKCU/software/myapp, i remember seeing an app that works like this but i cant remember which one
Thanks
Edit:
I tried making Foxit PDF Reader portable, here's the regkey part:
!define REGKEYS "HKEY_CURRENT_USER\Software\Foxit Software||HKEY_CLASSES_ROOT\.pdf||HKEY_CLASSES_ROOT\CLSID\{14E8BBD8-1D1C-4D56-A4DA-D20B75EB814E}||HKEY_CLASSES_ROOT\FoxitReader.Document"
For some reason it succesfully exports all 4 keys, but
HKEY_CLASSES_ROOT\FoxitReader.Document
and
HKEY_CLASSES_ROOT\.pdf
and all the subkeys remain on the registry after closing.. am i doing something wrong?
thanks
I just figured that HKEY_CLASSES_ROOT and HKEY_LOCAL_MACHINE\Software\Classes are hotlinked, so adding HKEY_LOCAL_MACHINE\Software\Classes\FoxitReader.Document and HKEY_LOCAL_MACHINE\Software\Classes\.pdf to the previous example did the trick.
Thanks for this awesome script
Thanks Knivez, works like a charm.
Now, I noticed that when launching FoxitReader from a local/portable installation, you've got the ads in the upper right corner. One might think, View -> Untick "Advertisements" and you're done. The problem is, the next time you launch the app , the ads come back.
What I did, I made a portable version using PAT, went into the following folders "Data -> Settings" and edited "RegKey1.reg".
Open the "RegKey1.reg" and delete "AdvertiseIndex"="number"
One thing I am missing or just couldn't find, is the possibility to choose whether you want to use local or portable settings upon launching the portable application just like in "QuickPortTemplate"
Any suggestions?
PS: Oh I forgot, brilliant script! Thanks heaps.
A possible way should be modifying the portable .regs to reflect the local entries but it should work only if the app itself doesnt change them..
Ive noticed too that once closed, the wrapper "wipes" any local settings too (it would be awesome if it restored them instead) for example, lets say i want to use my Foxit reader in a computer where PDFs are associated with Acrobat Reader and i don't want to change anything. If open and close Foxit (compiled with the settings i posted earlier)the original pdf associations will get deleted as well. Not much of a concern trough i can live with that
Oh i'd also like to know if there's a limit of the # of reg keys a launcher can manage without problems. I'm considering making my MediaMonkey portable and it creates a huge number of entries each time is launched so i was wondering if it was possible to cover every key.
Regards
@ knivez
I ported an application that had about 10 registry entries without any problems.
Now, what about those directories (RegistryBackup and SettingsBackup ) then?
It is stated that both will be dynamically created, I have never seen them though ...
Am I not getting it the right way ?
... that apparently is not neccesary to mirror HKEY_CLASSES_ROOT and HKLM\Software\Classes\, its just enough to point to the latter when compiling the loader. It confused me a bit since i use Total Uninstall to monitor changes and it only reports HKEY_CLASSES_ROOT instead of both.
porter: -RegistryBackup and SettingsBackup are working fine here. The folder(s) are created in the Data dir and get deleted when the app closes.
Alright, I've just noticed that thanks
Well they will be only created, when an existing regkey is found. After closing the Portable App again, the backup is restored to the Registry again and the directories RegistryBackup and Settingsbackup are deleted automatically.
I was trying to work on making Omea Reader portable. It creates over 100 registry entries. After adding the keys in the .nsi file, i tried compiling it. It throws an error message. It seems like it doesnt support large number of reg entries. Is there a work around to this? Like adding all reg entires in a file. And then asking the script to import the reg entries in the file? I am new to NullSoft scripting...still on the learning curve. Can someone help me out with this thing?
Thanks,
Sam.
if you try to add a complete branch and not only one key. This should work then.
Most application I know create maximum maybe 4-5 branches which might conatin some subkeys.
I would be interested in a portable Media Monkey, even imperfect (provided it's legal).
i've tried to create a portable version of WinImage, and i've got the following problem :
after i run the portableWinImage, it deletes the WinImage resitry keys completely.
If i modify the template, and i comment out the lines :
StrCpy "$ACTION" "DeleteKeys" ; delete registry keys on host computer
Call DoAction ; just do it
at line 406 and 407, it doesn't delete the keys and restores the old registry settings, BUT, if there was no registry key to start with, it still leaves the key behind.
From what i can see, there's a problem and the RestoreKeys is not called after the DeleteKeys.
Is there a way around this as i'd like to be able to restore the old registry settings if there was any, but still don't leave any traces if there was no registry entry.
thanx in advance.
EDIT :
I've just looked at QuickPortTemplate, and i've seen a little trick there. After running DeleteKey and RestoreKey it uses a litle delay
Sleep 500
before deleting the temporary registry file.Maybe that's the problem here, the registry file might be deleted before the registry plugin manages to import its content.
EDIT 2:
After a few tests, i've managed to make the code work, here's how the last part of the file looks like (at aboutline 402)
!ifdef REGKEYS
StrCpy "$ACTIONPARAMETERS" "${REGKEYS}" ; hand over parameters list
StrCpy "$ACTIONDIRECTORY" "$DATADIR\Registry" ; define where local keys are
StrCpy "$ACTION" "BackupKeys" ; backup existing registry keys
Call DoAction ; just do it
StrCpy "$ACTION" "DeleteKeys" ; delete registry keys on host computer
Call DoAction ; just do it
Sleep 1000 ; this delay is needed, so the registry writing can be finished before the temporary REG file is deleted
RestoreOldReg:
StrCpy "$ACTIONDIRECTORY" "$DATADIR\RegistryBackup" ; define where to backup keys
StrCpy "$ACTION" "RestoreKeys" ;restore saved keys
Call DoAction ; just do it
Sleep 1000 ; this delay is needed, so the registry writing can be finished before the temporary REG file is deleted
EndRegKeys:
!endif
The ideea is that i've included the 1000ms delay both after deleting the regkey and after restoring the backup, this seems to work just fine.
There's no teacher who can teach us anything new
He can just help us to remember the things we always knew!
E N I G M A
Nice work there albuemil ,
This way, old settings are restored upon shutting down the portable app.
Thanks I'll add this and update it.
Thanks for the help rmccue, although I figured it out myself after a few days (after checking out the code of portable photoshop and the nsis documentation). Maybe I asked it too early...
for some reason after creating "WordWeb Pro" into a portable app it keeps creating a "history.txt" file in the directory where the PortableWordWeb.exe file is kept. Is this normal, and if so how do i stop it, and if not, what am i doing wrong?
Thanks
version 1.2 out now
Any chance of adding checking for multipul instances in this fantastic template? Or am i just blind and not configured it properly...
Do you mean mulitple starting of the launcher? This is not handled currently. Is this a topic? Then I would have to implement this.
I added checking for the second launch of the portable app with version 1.4.
Current version of NSIS is 2.20 - it is stated (in the template) that it is written for NSIS 2.17
Does anyone know if it can be used with NSIS 2.20 ?
Kind Regards,
Dennis Hestbech
have not problems, if it does post em and we'll have a look.
Yours
Steve Lamerton
Simply the first design was made on NSIS 2.17. I'll change the comment..
In the function :
!define SPLASHIMAGE "${PNAME}.jpg"
It apears an error, says that the image it's not found. Some suggestions?
Did you name the image correctly? e.g. "InkScapePorable.jpg"?
Becaus here I do not get any error message.
During the time I testing in some project, I can't compile with the PAT 1.4, but I can compile with PAT 1.3.
Blog for Portability
http://blog.eafriends.com
for solving this problem?
Upload NewAdvSplash include, it's now giving me some errors about it now.
Am I missing something?
I don't see any of the supporting .nsh files in the zip
Registry.nsh
WordFunc.nsh
FileFunc.nsh
I admit I'm new to this, but should it really be this difficult?
-Zac
the NSIS website and download them separately.
----
Ryan McCue
Cube Games
Life is like a sewer. What you get out of it depends on what you put into it.
(Tom Lehrer)
"If you're not part of the solution, you're part of the precipitate."
Hello Klonk. Thank you for your wonderful template (v 1.4). I spent about 4 hours last weekend creating about 10 portable app launchers, testing, extracting icons, etc., replacing Reg Rapper. Love it!
First question is generic. What is the environmental variable for My Documents? $PROFILE? I googled for about 20 minutes, but either could not find the correct variable or did not implement it correctly in the script.
Second question is more specific. I tried to compare your PAT 1.4 script with John T. Haller's script to see what the differences are. Since I do not know NSIS, I spent an hour and then gave up. What are the major differences?
Last question. Does PAT 1.4 store settings directly in the Data\Settings directory or does it store it on the Host computer and then copy to the USB stick's Data\Settings directory?
Again, thank you very much for having made this template.
CD
The answer to my first question is $DOCUMENTS.
Found it on nullsoft's website by "accident".
Settings are stored on Host computer (in normal non-portable place) and then copied to USB stick and deleted from Host computer.
Indirectly, this answers part of the second question as well...because I think that John's script stores settings directly on the USB stick?
is based off John's launchers, however it is easier to change and also supports working with the registry.
----
Ryan McCue
Cube Games
Life is like a sewer. What you get out of it depends on what you put into it.
(Tom Lehrer)
"If you're not part of the solution, you're part of the precipitate."
What am I doing wrong?
[CODE REMOVED - POSTING SNIPETS OF CODE IS FINE. POSTING 300 LINES OF CODE IN A FORUM IS NOT]
to my email: cubegames@gmail.com
----
Ryan McCue
Life is like a sewer. What you get out of it depends on what you put into it.
(Tom Lehrer)
"If you're not part of the solution, you're part of the precipitate."
Hi Klonk and everybody,
Can you please help me with something? As mentioned in an earlier post, I have successfully created about a dozen launchers with PAT 1.4 and they all work flawlessly! Thanks again.
There was one program, Deknop (a graphic button maker), with which PAT 1.4 does not seem to work correctly (or with which I do not seem to do correctly). The launcher works, but the registry entry is not deleted when the program is closed.
This is the registry key that I copied from Regedit: HKEY_CURRENT_USER\deknop
This is the code snippet:
!define REGKEYS "HKEY_CURRENT_USER\deknop" ; insert regkeys to use separated by "||", comment out, when not used
Is there something special about a registry entry in the HKCU root that makes PAT 1.4 less effective?
Please remember that I used PAT 1.4 for a dozen other programs that all work correctly so although it could be human error, it would be a repetitive human error (which seems to delete registry keys in the other programs).
Thank you. CD
Hello,
Can someone tell me how to get started?? All I see in the zip is an .nsi file (??) Do I need some kind of NSIS software or something?? I'd love to be able to create my own portable apps and I DO KNOW what I would have to find out and stuff like that, but can anyone help me here??
Thanks
Hi Klonk,
I noticed from your website that you evolved to version 1.4.1. I don't read German so cannot tell if you wrote this on your website (and I could not find your email address). Can you tell me what improvements/changes you made? Otherwise I'll just review the code...but that takes much longer!
I'd like to also request a new feature in version 1.5 (if there will be one). Can you add files and/or directories to delete once the application is closed? Implementation like you did for unlimited registry keys, setting files and settings directories would be ideal.
I ask because Audacity 1.32 Beta, makes temporary directores that need to be deleted after program close. I don't want to copy these to my USB key because they are generally very large uncompressed audio (WAV?) files.
Thank you.
1.4.1 is just a bugfix thing, nothing new and fancy.
Unlimited settings files and settings directories are already supported...
Assistance please.
Testing this will NSIS 2.22, and NSIS 2.20, I come upon an error, that seems to be with the Registry.nsh that is downloadable from the NSIS site. I'm getting:
Invalid command: ${registry::KeyExists}
The Registry.nsh is the one available here:
http://nsis.sourceforge.net/Copy_Registry_Key
I just bought a U3 stick earlier today. I'd LOVE to be able to make Quicken portable for use with it. Of course this will be just for my own personal use.
But I didn't see anything about using this to make apps U3 compatible.
Are there any tutorials available to make them U3?
Don
Don
is something really special which you need some special U3 API for it. I doubt that there is a way to create a launcher with NISIS to get something U3 capable.
for providing this template. Created a launcher for Tunnelier (graphical SSH client with SFTP from bitvise.com) and it works a treat!
Waiting on feedback from bitvise about hosting this launcher for the community.
For those of you getting started with this template (an excellent one, BTW - Thank you for providing it), you need to download and install several additional plug-ins for NSIS.
Go to the NSIS Plug-ins page at http://nsis.sourceforge.net/Category:Plugins
Download the following plug-ins: NewAdvSplash, Registry & FindProcDLL and install them.
-Jeff
-Jeff
try Ryans Plugin Pack
"What about Love?" - "Overrated. Biochemically no different than eating large quantities of chocolate." - Al Pacino in The Devils Advocate
are u gonna remove default directories? like john has? so it doesnt autoprobe for directories, just a waste of CPU time
Slackware 12 for system
MCP (For XP and Server 2003)
Network + Certified
aim is "nycjv321" (minus quotes)
Since it's a template, it should cater for all possibilities. Feel free to remove the redundant code for your own particular implementation...
As John is currently releasing a bunch of updated Apps I really hope that he will add InkscapePortable at last... now that there's the brand new version 0.45.
NSIS 2.23 generates with the InkscapePortableSource.zip from 19 Oct 2006 an .exe which just consumes all CPU without doing something visible...
with NSIS 2.24 and using the actual Inkscape Portable source. works fine...
I have the same problem with an other app (my first).
Did you solved your problem somehow?
I tried it with diffrent NSIS Versions (at the moment with 2.24). All have the same effect.
whether there is some loop or something. Or some wait for application start.
i think its nice but how can i make this file to an exe file?
with NSIS
I tried this. But the exe created is blank and when run complains about not finding the exe I specified. I am not a programmer. Does anyone have a start to finish tutorial for this using some application thats small and opensource?
You simply have to change those lines (comments are quite self explaining)
; **************************************************************************
; * Define constants
; **************************************************************************
!define AUTHOR "" ; your name
!define APP "" ; insert application name, e.g. "TestApp"
!define VER "0.0.0.0" ; insert version of launcher
!define EXE "" ; insert program exe name, e.g. "testapp.exe"
!define PNAME "${App}Portable" ; format of portable name (dirs and filenames)
!define ICON "${PNAME}.ico" ; comment this line out when default icon should be used
!define SPLASHIMAGE "${PNAME}.jpg" ; comment this line out when no splashscreen image should be used
!define REGKEYS "" ; insert regkeys to use separated by "||", comment out, when not used
!define SETTINGSFILES "" ; insert settings files to use separated by "||" as stored on the host computer, e.g. "$WINDIR\TEST.INI", comment out, when not used
!define SETTINGSDIRS "" ; insert settings directories to use separated by "||" as stored on the host computer, e.g. "$PROFILE\TEST", comment out, when not used
You should also take a look at the readme.txt regarding the necessary directory layout.
For REGKEYS, SETTINGSFILES, SETTINGSDIRS: You have to fidn out yourself where the application you want to start stores its settings. There are several tools out there monitoring registry or file acccess..
Added the requirements...
Hello,
If my registry key is like this ,whats the format i have to enter it in the template.
(+)(REG KEY)HKEY_CLASSES_ROOT\CLSID\{195B5D84-DAD1-11D3-AA5F-00105A6F87AB}\InprocServer32
(+)(REG VAL) ThreadingModel = 'both'
(+)(REG VAL) (Default) = 'C:\Program Files\SIPLink\dXDBInsp.dll'
Thankyou
I think the folowing should work:
!define REGKEYS "HKCR\CLSID\{195B5D84-DAD1-11D3-AA5F-00105A6F87AB}\InprocServer32"
In the NSIS help you can find the "HKCR" thing at the function "WriteRegExpandStr"
If the executable can't be found, the script goes into an endless loop - leaving you hanging (pun intended).
Notice the reference back to "CheckAppsDIR" if the file is not found?
Here's my guess as to the fix... using a new label "NoExeFound"
BTW - This is a great script, Karl! Thanks for posting.
you're right, this is a bug. I'll fixed this in the source and updated it to my homepage.
Would you mind if I included the template with the NSIS Portable on my website?
For those who have fought for it, freedom has a flavor the protected will never know.
"Because they stand on a wall and say, 'Nothing is going to hurt you tonight. Not on my watch.'" (A Few Good Men)
Coincidence is God's way of remaining anonymous.(Albert Einstein)
Hello,
Can someone tell me how to get started?? All I see in the zip is an .nsi file (??) Do I need some kind of NSIS software or something?? I'd love to be able to create my own portable apps and I DO KNOW what I would have to find out and stuff like that, but can anyone help me here??
Thanks
P.S. Please delete the one at the top...I can't figure out how to comment without replying
Hi, erm... I think this is a great script and all, but I get this error:
Error while setting icon to "$LimeWire.ico": can't open file
The code that I am using to get the icon is:
!define ICON "$LimeWire.ico" ; comment this line out when default icon should be used
And also, what does it mean: comment it out?
Cheat King
----------
Cheat King
----------
Commenting is putting a semicolon in front.