Do not use this. Use the PortableApps.com Launcher instead.
Discussion has moved here:
https://portableapps.com/node/10491
What ist it for?
It helps you to create a clean portable application. This means no traces are left on the host computer and the application doesn't (normally) have to be changed in any way. (Maybe some configuration files)
Where can I get it?
http://www.loncarek.de/downloads/ApplicationPortableTemplate.nsi
use "Save As..." in your browser.
The license and more information could be found at the end of the source.
What to do to make an application portable?
1. You install the application you want to make portable on your computer.
2. You monitor which files, folders, and registry keys are generated. (There are several helper apps for that task).
3. You insert the monitored information into the constants at the beginning.
4. Then create a correct directory structure and compile the script with NSIS. Create an launcher icon.
5. Copy your application to the appropriate APP folder and also the launcher.
6. Run the launcher.
That's it...
It might happen that some applications need some additional handling, but that should be left to intermediate/advanced users as some routines would have to be added.
How does it work?
Existing Application files and folders are renamed. Registry keys saved. Then the files/folders/registry keys of the portable application are applied. Finally the Application is launched.
When the application is closed all files/folders/registry keys are saved within the data directory of the portable application and all original files/folders/registry keys are restored.
One special thing (since version 1.6): The users profile folder is redirected to the portable data directory
Which application can I make portable?
Almost every application as far it does not implement itself too deep in the system. Also some commercial applications could get portable. But then respect the license or offer only the source to others.
What license?
The license is a 2-clause BSD-style license. (see source for details)
What is needed?
In order to compile this script with NSIS you need the following Plugins:
- NewAdvSplash
- Registry
- FindProc
- Dialogs
Last tested with NSIS 2.28
History (since version 1.4):
Discussion/History until version 1.4:
https://portableapps.com/node/2022
1.5
- complete rewrite for intermediate users to understand easier what is going on, as discussed here: https://portableapps.com/node/6229
- integrated readme into source
- files/folders are now renamed -> should improve starting time a lot.
- error handling when backup files/folders exist
1.6
- compile flags added to decrease final launcher filesize
- users profile directory is now redirected to the portable data directory
- added check for non-existant data folders -> automatic creation
1.7
- added automatic creation of missing data directories
- automatic user profile redirection could now be also disabled
1.8
- added optional admin rights checking
- optimized compilation (when some constants are left empty and not commented out.
- minor bugfix
1.9
- when no directories are found a default directory structure is created
- when no EXE is found you are asked to select a folder from which to copy the files
- added possibility to integrate the sources if you want to distribute only the exe, e.g. when creating commercial/shareware applications launchers -> launcher is an installer at the same time
- added switch for INI file to disable the above automatic extraction
- some code optimizations
2.0
- registry keys are now stored in one single file even with multiple registry keys (not compatible to previous versions)
- Overrides setting of REGKEYS if USEREGKEYSFILE is "TRUE" and reads registry keys to process from file "Registry.reg"
- Added "Registry.reg" to source installation
- Added default command line parameters
- removed one possible directroy structure (which did not make sense)
- added GTK and JAVA (or better JRE) support, adjustable via INI
- automatic detection of a "CommonFiles" directory.
2.1
- bug fixes
- possibility to deltet registry keys before applying own (saved) ones
- added RequestExecutionLevel for better VISTA compatibility
2.2
- fixed newadvsplash DLL being left in the temp directory (forgot cleanup)
- changed way of restoring the registry keys (now uses "regedit /s")
- removed sleeps again (commented them out, just in case...)
- removed /D=2 switch when saving registry keys
2.3
- added a lot of "" around the variables, this should fix errors with empty variables
- cleared errors before any registry stuff
- added popup messages when something goes wrong when saving registry keys
Any comments/bug reports are welcome.
Yea, great!! - Thanks for these wonderful Application Templates, I have created several launchers and will go update them. Thanks again!!
you might want to check out this comment from john: here, before you make the USERPROFILE redirection a permanent part of your template.
I had used it in Reg Rapper, but stopped because of this conversation.
Hoep this helps.
Deuce
Portable Software: Just the beginning.
for that information. I didn't know that. I have an idea to solve that:
What about simply saving the original USERPROFILE in a variable. Change it and then in the end restore the original setting???
This should fix the problem shouldn't it?
But what about the programs you run while your "portable" USERPROFILE variable is active. Other programs wouldn't know about your changes and things still would get messed up.
"There is a computer disease that anybody who works with computers knows about. It's a very serious disease and it interferes completely with the work. The trouble with computers is that you 'play' with them!" - Richard Feynman
"What about Love?" - "Overrated. Biochemically no different than eating large quantities of chocolate." - Al Pacino in The Devils Advocate
with win2K and WinXP this never happened as the environment variable was only changed for the application run by the launcher. During run of the applicaton I opened CMD and did SET. And everything shown was fine.
thread enough.
It is true that when the first launched application starts another one the UserProfile is changed also for this second started application. Maybe I should make this switchable and add an comment on this topic.
I am new to both this topic and to NSIS, so I may be doing thngs incorrectly.
I have an old game (rummy500) that creates rummy500.ini in $WINIR.
The problem I am having, is that when rummy500portable.exe is executed, the program runs normally (creating $windir\rummy500.ini), but when I exit rummy500, the rummy500.ini file is deleted from $windir (as I would
expect), but it is not saved on the removeable media.
I have setup the default directory structure as described in "Portable Application Template v1.6.nsi".
This is my "configuration" section: [Line wraps marked » - RM]
More info:
If $WINIR\rummy500.ini exists when rummy500portable.exe is started, a back-up is created
($WINIR\Rummy500.ini-PortBak), and then restored to $WINIR\Rummy500.ini when the program is terminated. This is normal (a far as I can understand the script). But still,
no copy of rummy500.ini is saved.
BTW, I am using NSISPortable v2.25.
So, the question is, is it a bug or my configuration error?
Any help will be appreciated!
This file is not saved as rummy500.ini but as File1.dat in the settings subdirectory. Is your thumbdrive write enabled? Otherwise it won't work.
What Windows are you running?
Hi Klonk,
I have been experimenting with this script by running it from a second
internal hard drive (D:), so there is no write protect issue. This OS is
win98se.
After reading your post, I reset the directory structure (before runnning
rummy500Portable) to:
create a directory \Data\Settings\ in your directory with portable.exe and try again.
(This is the directory where the File1.dat should go).
BTW: I uploaded a new version 1.7 which has the creation of the data structure integrated, i.e. it also creates the \Data\Settings directory if it does not exist yet.
Hi Klonk,
You squashed that bug!:smile:
I downloaded v1.61 and went thought the entire test sequences again and
I am happy to report the all is well (well at least with the .ini parts)
I will now try to do some serious portability conversions. They will test more functions of the script.
Thanks for the quick response & fix.
Darn, I see you have already released v1.7, I'll download and do my tests with it.
Added a check for local admin access. This should work..
Constants Section
Main section (right after Section "Main")
New Function (put anywhere - right after the Main section is good)
This is mostly from http://nsis.sourceforge.net/Simple_tutorials
-Steve.
This will definitely help for those applications which require administartor access. But on the other hand, shouldn't a portable application work also without administrator access??
I haven't checked yet, but I could imagine that writing to some specific registry keys is only possible with administrator rights. Does anyone know for sure??
A truly "portable app" should not require admin access, but there are plenty of software packages out there there were not designed to be portable and do not follow the "rules" of a portable application.
The problem I had (have) is that a particular application required access to the HKLM (HKEY_LOCAL_MACHINE) registry key, which is unwritable by anyone besides a local administrator.
but implemented a little bit different (checking for value is done differently)
Klonk:
In attempting to get my non-portable application working from a USB stick, I added some registry management functionality to your template. It's nearly complete but still has a few problems.
In addition to the registry keys being managed by the REGKEYS constant, which requires you to list the registry keys, I added a REGFILES constant. By using this constant to list the external registry files, the template now contains the ability to manage more registry keys than is allowed by the 1024 character limit in String variables.
Also, this gives the template the ability to replace keywords in the registry files that would be parsed out at runtime, letting the user insert path-specific variables into the registry as required.
For example, in my external registry file I might have
[HKEY_CURRENT_USER\Software\Mindjet\MindManager\6\MyMaps\Folders]
"My Maps"="%USERDATAPATH%\\My Maps\\"
At runtime, the wrapper will replace %USERDATAPATH% with $DATADIR\UserProfile, put the result in RegKey#.reg file, then let the existing template functionality to import those keys as normal.
The variables that the template is currently replacing are:
%DESTPATH% = "$EXEDIR\App\${APP}"
%DATAPATH% = "$DATADIR"
%USERDATAPATH% = "$DATADIR\UserProfile"
I also added the CheckAdmin function from above, which seems to work for me.
I tried not to break existing functionality in the template, but it is not certain that I have succeeded in that.
There are a few outstanding issues with my changes, but one in particular is giving me trouble.
The Registry file parsing works correctly, but in order to maintain a list of keys to add/remove when the installer starts/exits, the script builds a list of "base" registry keys. That part doesn't seem to be completing when there is more than one registry file to parse. I'm not sure why.
The application that I am using to test my modifications requires about 1000 registry keys, 70% are in the HKLM tree. This is probably considered a "large" application for this type of script, but I would still like to see it work.
Anyway, are you interested in these modifications?
-Steve.
I'm definitely interested to add such functionality as addition. I was not aware of the limit of 1024 characters which might be filled quite soon (especially with registry keys) but this might be also interesting for configuration files and also directories. I would look over it and try to implement it in an transparent manner.
Just a question: Which application writes 1000 registry keys???
BTW: I released version 1.8 which integrates the admin checking
How should I get it to you?
After installing MindJet MindManager, the registry difference was over 2200 keys added! After taking out everything but the "parent" keys, it still comes in to just over 550 keys.
-Steve.
please send it to dh2mll [at] web [dot] de
Thanks.
I made some own thoughts and have some ideas about regfiles.
I also have some other stuff in plan which I thought would be handy in distributing launchers for shareware/commercial applications.
I'll check it out and see what makes sense to integrate into the template in my eyes. Maybe I integrate some stuff with version 2.0...
BTW: I released 1.9.
@sbabinea: The new changes won't help you much currently thus there is no need to update for you.
Do you want me to integrate my changes into version 1.9 of your template? It might save you some time but you will have to slow down with the releases
Now this template includes everything I really wanted.
Your changed are a lot of stuff and I'll see whether I'll implement it or not. Because your changes are very special and I'm not sure whether they are widely needed. Maybe I can find a different way of storing multiple regkeys/files/folders.
The only thing that might happen to this version: some minor bugfixes.
Just one question: in your version of the template you are registering DLLs before launching the application. Why?
@sbabinea: Your modifications of the template are very interesting. I have been having problems creating certain portableapps due to the 1024 char String variable limit.
Is there any chance that I can get a copy of your modified template? It appears that this functionality will be implemented (in one form or another) into ver 2.0, but I would really appreciate the opportunity to study your modified code in order to better my skills. From what I understand after reading your posting, the process of defining registry keys could be done in the standard way (with the 1024 limit) or by defining an external registry file (I would just export the registry changes via Total Uninstall [.reg file]) and simple set that .reg file as the external registry defined in the constants. Correct?
Anyway, please consider letting me have a copy of your template. Thanks.
@Klonk: Just wanted to say thanks for taking the time to create such an excellent NSIS script. You have opened the world of PortableApps to myself and others. You rock!
-wtrabbit
please do not expect a version 2.0 too soon. I worked almost every day recently on the actual version.
As sbabinea showed it is possible to save/restore mutliple registry keys. One thing should be clear! Copying/saving that much registry keys could take some time!!! There should then be some kind of warning/message IMHO.
I merged my changes with Klonk's version 1.9.1 and posted it here: http://thebabineaus.com/software/PAT/PAT_sab.nsi
I still haven't gotten my application to work with it yet so there may be more changes
Namely:
- Add support for multiple reg files. Originally I had support, but I took it out so that I could package my reg files using the new INSTALLSOURCES option.
- separate the DLLs to their own constants (have REGDLL1, REGDLL2, REGDLL3 constants instead of 1 REGISTERDLLS constant. This will let me use InstallLib)
- Add support for adding/removing hidden registry keys
If you end up using my version, please do not bother Klonk with problems.. Post a new thread and ask me
-Steve.
Hi Klonk,
What exactly does this mean?
- added possibility to integrate the sources if you want to distribute only the exe, e.g. when creating commercial/shareware applications launchers -> launcher is an installer at the same time
Also, do you have a roadmap of what other options/improvements/evolutions you have for future versions of PAT?
Thank you and keep up the GREAT work!
This means when INSTALLSOURES is set to true that the sources are compressed and integrated in to the launcher. When running the launcher and the directory structure does not exist yet, i.e. the sources are not there. They will be decompressed automatically.
This is meant only for convenience.
Let's assume the following situation:
You created a great launcher for a shareware application and want to share that launcher. You want also to give the sources (because of some useful information) or a readme.txt.
The only thing you have to give away is the launcher.exe. As soon launcher.exe is started the directory structure is created, the source and readme.txt are copied into the directory tree and the user is asked to select the directory of the locally installed shareware application. Then that application is copied into the directory structure.
It's difficutl to explain. I means to create a launcher that might also be used as some kind of portale apps creator.
For roadmap: Well there is no real roadmap. Currenlty it has everything wanted. It lives from the suggestions of the users. Maybe I'll include some of the changes suggested above.
Thank you. This is clear now.
The only roadmap I could think of is:
*Change to PAF format as soon it is released (maybe automatically create AppInfo files and directory structure.
At line 382 (v1.8 ) , after copying the $DATADIR\Settings\File$R8.dat to
the destination directory, the code falls through to copy the existing
host file over the just copied $DATADIR\Settings\File$R8.dat. The net
effect is to run the portable app with the file that existed on the
host instead of with the portable app file.
Insert after line 382 (v1.8 ) or after line 446 (v1.9)
Goto InitFilesLoop
before change
after change
There may be a better (or prefered) fix, but this does work.
same bug also for folder copying, i.e. forgot copying existing folder if no portable settings exists. fixed that.
New Version 1.9.1 ready for download...
Please see my posting above. Sorry about the double post. Many thanks again!
-wtrabbit
Klonk:
Lines 328-337 present a small bug. If ADMINREQUIRED is set to true, then even if the logged in user has administrator access the program will abort.
The solution is to delete lines 335-336.
-Steve.
thanks, I forgot to remove this (had it for testing)
fixed with 1.9.3
I uploaded the corrected version.
I updated my sources here: http://thebabineaus.com/software/PAT/PAT_sab.nsi
-Steve.
I saw your launcher here: https://portableapps.com/node/6924
This is a good idea to offer others all your changes.
I plan to add support for external configuration files which might contain a list of reg keys and/or a list of files and/or a list of folders. I will support multiple files containing lists.
Therefore I did some code cleanup with version 1.9.4 (no functional change, simple moved some code to a helper function) as preparation for those lists.
Work on the source is slow currently as am around a lot because of my real job.
Dear Karl,
I made a suggestion to John Haller in order to be more flexible with the use of a GTK or a JRE with a portable application. See it here.
It would be great to include this suggestion in your template!
Kind regards,
Bertrand GILLIS
I have to look into it and how it was done for portable Openoffice. JRE portable was integrated into the german portable openoffice. I'll into it how they did it.
There are several ways how to define the JRE or GTK version.
1. set the JRE/GTK directory directly from an portable applications INI file
2. set the JRE/GTK directory from within the PAT source
3. set version number within PAT source and search where it is installed and use that directory structure.
I personally think 3. would be the best solution.
What is an jreportable.ini needed for? Can anyone explain that to me?
Karl,
I've already look at OO launcher source code. It takes JRE version directly from a javaportable.ini file. Based on three values extracted from that file, the launcher creates dynamically an xml file used by OO to locate the JRE. That's why I propose to rename the INI file to jreportable.ini instead of javaportable.ini.
Personally, I don't think "solution 3" is the best solution. As a matter of fact you must recompile a new launcher each time you want to use an application with another JRE. I think the best of both world would be:
- set the JRE/GTK version directly from a INI file (read by the launcher)
- search where this version of JRE/GTK is installed and use that directory structure (from the launcher).
That's what I try to explain in my previous post here.
I'll allow an INI entry for setting the commonfiles directory (for some own directory structure) and also automatic setting of the commonfiles based where the portable apps EXE could be found. I think this is really best.
The only thing is that creation of an XML file is highly specific to OO. Other applications could require something totally different.
How to handle that case? Or is it simply sufficient to provide a variable to the user to point to a common files directory? I'm not sure how to make use of it in a universal way..
The version number could be obtained from the directory name itself.
BTW: I think it is not a good idea to use JRE and GTK first level priority in your list of directories. (I could support it though)
I think this directory structure would be best:
+-\ Portable.exe
+-\CommonFiles\ \ .exe
+-\CommonFiles\ Portable\
+-\App\
or
+-\ .exe
+-\PortableApps\
+-\CommonFiles\ Portable\
+-\App\
or
+-\ .exe
+-\CommonFiles\ Portable\
| +-\\
...with the directory structure.
Unfortunately I don't think it's a good idea to use the directory name to get the JRE/GTK version. Several JRE/GTKs could co-exist within directory "CommonFiles".
For example, Apache Tomcat 5.x needs JRE 1.5 or higher but other applications may need JRE 1.4... and not higher otherwise the application migth not work anymore. Multiple JRE/GTK must then co-exist within directory "CommonFiles".
Then, how will you determine the right JRE/GTKs to use for a specific application ? That's why I introduce the concept of using different level where the jreportable.ini/gtkportable.ini could co-exist.
I know that the creation of an XML file for OO is specific. But if we could have a standard JRE/GTK variable allocation based on a standard JRE/GTK location, it will be a good start for specific customization in NSIS script.
I'd really like to have John Haller's opinion on that.
named e.g. CommonFiles\JRE1.6.0_1
Here the version number is totally clear and therefore no need for an additional INI.
I thought: when you create a launcher you could define which version is needed. For example:
!define USEJAVAVERSION "1.6.0_1"
or something similar. Of course there must be a possibility to override that in the portable apps INI (in case of a newer version that might work or is needed with an update)
Still the problem: How should the application know that there is a portable java and where to search for it? Setting registry keys would lead to bigger problem if another application runs that uses JAVA.
My big problem: I currently do not know how java integrates into the system. (the same problem for GTK). But maybe we should discuss that in a separate topic.
as you suggested it. You can find it here.
I've also tried to answer to your last question: How to know which GTK/JRE an application shoud use and integrate into the system.
I see John is recommending:
?:\PortableApps\OpenOfficePortable\App\Java
?:\PortableApps\CommonFiles\Java
I've updated my specific topic about JDK/JRE suggestion with detailled directory structure and other relevant information. Please have a look and leave me any comment.
Personnaly I don't think John's directory structure is totally appropriate because it doesn't enable the coexistence of several GTK/JRE with different versions.
?:\PortableApps\OpenOfficePortable\App\Java doesn't need any version number in the directory structure. But I think the other one ?:\PortableApps\CommonFiles\Java needs it to make possible the coexistence of several GTK/JRE with different versions.
possible directory structure as it didn't make sens anyway. I will release it with version 2.0.
Roadmap: integrate GTK/JAVA support before release of 2.0.
Suggestion HERE https://portableapps.com/node/6956
would make good addition to Template.
"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)
but I dont' have a clue how to realize that in NSIS.
I integrated that feature in my own application launcher, which is really minimalistic. It just monitors when the application is launched and tries to find out which window ID it uses. But still some applications do not close automatically when sending the WMCLOSE message. Still haven't found out why..
Hi Klonk,
I tried compiling PAT 1.9.4, but get the following error in NSIS Portable (v 2.27).
Abort: ""
Invalid command: Dialogs::Folder
Error in script "B:\FotoGraphics\Noiseware\NoisewarePortable.nsi" on line 338 -- aborting creation process
For reference, the changes I have made are quite simple. I have registry injection/cleanup and have commented out almost all the other items as seen below:
!define APP "Noiseware" ; insert application name, e.g. "TestApp"
!define VER "1.1.0.194" ; insert version of launcher
!define EXE "Noiseware.exe" ; insert program exe name, e.g. "testapp.exe"
; ----- Application specific stuff
; insert regkeys to use separated by "||", comment out, when not used,
; e.g. HKCU\Software
!define REGKEYS "HKEY_CURRENT_USER\software\Imagenomic"
; insert settings files to use separated by "||" as stored on the host
; computer, e.g. "$WINDIR\TEST.INI", comment out, when not used
; !define SETTINGSFILES ""
; insert settings directories to use separated by "||" as stored on the
; host computer, e.g. "$PROFILE\TEST", comment out, when not used
; !define SETTINGSDIRS ""
; Require local administrator rights to run the launcher, necessary
; when writing to e.g. HKLM registry key. If not required comment out
; !define ADMINREQUIRED "TRUE"
; Redirect Userprofile folder, comment out when your application calls
; other programs, i.e. to disable automatic redirection. Default value
; "TRUE".
!define REDIRECTUSERPROFILE "TRUE"
; When "TRUE" a launcher is created that contains the sources and
; copies them into the appropriate folder if they do not exist yet.
; !define INSTALLSOURCES "TRUE"
In addition, I have commented out the splashscreen and have turned off the CRCCheck.
For reference, the problem line (338) is below:
Dialogs::Folder "Select installation folder of ${APP} " 'Select the main folder where you installed "${APP}" on your harddrive:' "$PROGRAMFILES" ${VAR_R0}
Would you know what is going on? Thanks. CD
By the way, you and Steve are doing a marvelous job with the PAT/PAL. I am having a very difficult time deciding whether I prefer the idea of compiling my own launchers (PAT) or whether I just want to modify an ini file (PAL)...decisions, decisions, decisions...
Get it here.
Had the same problem so I knew about the plugin.
“Science is the belief in the ignorance of the experts” - Richard P. Feynman
"What about Love?" - "Overrated. Biochemically no different than eating large quantities of chocolate." - Al Pacino in The Devils Advocate
Great! Works like a charm.
Silly question: Do I need the nsi scripts and the SerialMaker.exe file or are they just examples? I only need the Dialogs.dll and defines.nsh files, right?
Thanks again.
What I did was:
I put the Dialogs.dll into the Plugins folder and the defines.nsh into the Include folder.
The nsi files aare examples and the rest is ignorable.
“Science is the belief in the ignorance of the experts” - Richard P. Feynman
"What about Love?" - "Overrated. Biochemically no different than eating large quantities of chocolate." - Al Pacino in The Devils Advocate
Thanks!
Klonk, would it be possible to define the PROGRAMPARMS variable within the PAT instead of having to use an external ini file? I am thinking of something like the "--vlm-conf" settings of John's VLC Portable launcher...
Thanks. CD
command line options within the constant EXE. But I agree it would be much clearer if a separate constant will be used. I'll add it to the upcoming 2.0 version.
check my post below "guess no one is passing arguments", specifically the strcmp and strcpy debug code.
it allows you to set a default argument and still be able to pass in an argument.
-----------------------------------------------------------------------------------------------
Because they stand on a wall and say nothing is going to hurt you tonight. Not on my watch.
"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)
1.4 - 1.9 do not pass arguments.
Just to clarify this is when passing argument from command line or from menu like ASuite, I didn't test with ini file.
Using PortableFirefox as a guide I came up with the following to fix it.
the commented lines are just test code.
you will need the GetParameters.nsh you can copy it from the firefox portable source folder.
-----------------------------------------------------------------------------------------------
Because they stand on a wall and say nothing is going to hurt you tonight. Not on my watch.
"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)
in my ow tests it does pass arguments using the code below
Of course FileFunc.nsh should be available within the NSIS Include directory. In a normal installation it is available.
Could you please test with your installation and tell me whether it works? Thanks for your help.
It probably does work, however EXEPARAMS is not in the template only PROGRAMPARMS
also if PROGRAMDIR\PROGRAMEXE is the path and executable, and EXEPARAMS is the argument, what is the purpose of PROGRAMPARMS?
I don't believe R0 should be included in the quotes as it isn't part of the command being executed.
I believe the quotes have to be done as in my example above in order to work on win98/95 in case the path has spaces or something, its in the NSIS help.
I'm still new to NSIS so I could be mistaken in any of this but I believe the syntax in my example would be the more appropriate way to do it.
-----------------------------------------------------------------------------------------------
Because they stand on a wall and say nothing is going to hurt you tonight. Not on my watch.
"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)
EXEPARAMS comes from the upcoming version 2.0 of the template.
With that constant you can define some default parameters which will be used on every launch and cannot be disabled.
The argument consists of ${EXEPARMS} $PROGRAMPARMS and $R0.
And in this case $R0 is executed as an paramter.
Of course I could have used some other ame maybe $CMDPARAMS or whatever. This does not make any difference.
Example:
Lets Assume:
PROGRAMDIR="D:\prog"
PROGRAMEXE="test.exe"
EXEPARAMS="--default"
PROGRAMPARMS="--ini-setting" (is set from within the INI file)
You run the application from the commandline like this launcher.exe --cmdline
Then the call of the application looks like that:
ExecWait "D:\prog\test.exe --default --ini-setting --cmdline"
Ok, now I understand why you are passing multiple parameters.
But I tested Template 1.4.1 and 1.9.4 and neither of them would pass the argument.
It might be because my path has spaces in it? Sorry, should have mentioned that from the beginning.
I found this in the NSIS help....
Note, if the command could have spaces, you should put it in quotes to delimit it from parameters. e.g.: ExecWait '"$INSTDIR\command.exe" parameters'. If you don't put it in quotes it will not work on Windows 9x with or without parameters.
But if you quote it like the example NSIS gives you errors about to many parameters that ExecWait only excepts 2.
Your actually passing it 4 params but quoting it as one single param.
EDIT: OK, I found the actual problem. I'm actually trying to do the same thing you are with EXEPARMS, pass in a default argument.
The problem is that the application I am launching only excepts 1 argument, so setting a default and then trying to pass an argument from the command line causes the application to ignore the second argument, the one from the command line, it will always only recognize the first argument being passed which in the default currently.
I believe you will have the same problem with your new addition of EXEPARMS.
Most applications will only except a certain number of arguments and will ignore the rest. Also if your default argument conflicts with one passed by command line which will the application use? Probably the first which is the default, but this eliminates the ability to pass command line arguments if you have a default set.
-----------------------------------------------------------------------------------------------
Because they stand on a wall and say nothing is going to hurt you tonight. Not on my watch.
"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)
Just wanted to separate this from the above since it was getting rather long.
I think a better way to handle the arguments because of the above issues would be..
Command Line arguments override Ini File arguments and
Ini File arguments override default arguments.
Pseudocode Code:
copy defaultargs to argument
copy iniargs to argument (overwrites\overrides)
copy comargs to argument (overwrites\overrides)
execwait exec argument
-----------------------------------------------------------------------------------------------
Because they stand on a wall and say nothing is going to hurt you tonight. Not on my watch.
"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)
Default Value
StrCpy "$PROGRAMPARMS" "portable" (initialize variable to default value in first code section)
Ini File Value
Current code will overwrite default with ini file value if ini file exists,may need to include check not to override a good value with an empty one if ini file exists but has empty value.
Command Value
I haven't tested this with an ini file, but the default value and command pass work as they should.
-----------------------------------------------------------------------------------------------
Because they stand on a wall and say nothing is going to hurt you tonight. Not on my watch.
"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)
Nice movie and especially a VERY NICE Jack Nicholson.
But the others are good too.
"I want the truth!"
"You cant handle the truth!!!!!!!!!"
“Science is the belief in the ignorance of the experts” - Richard P. Feynman
"What about Love?" - "Overrated. Biochemically no different than eating large quantities of chocolate." - Al Pacino in The Devils Advocate
It was a REALLY good movie. I think it was nominated for something like 6 or 8 awards.
I like that particular line though cause it speaks volumes about the Marine Corps and how some people view them.
-----------------------------------------------------------------------------------------------
Because they stand on a wall and say nothing is going to hurt you tonight. Not on my watch.
"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)
I'll do it that way.
I also will change the quotes to make sure that exes with spaces in their names could be launched also.
Will be integrated into 2.0.
now with a bunch of additions (see history in first post)
One more suggestion...
Most of the time portable registry keys or portable files (eg. INI files) must be adapted dynamically in order to update directory or file path; in particular, the drive letter of the portable device. How to deal with that kind of requirements ?
These changes could be applied before processing portable registry keys or portable files. A new function call "InitBeforeReg" and/or "InitBeforeFiles" could then be introduced in the section "Main".
And/Or
These changes could be applied after processing portable registry keys or portable files. A new function call "InitAfterReg" and/or "InitAfterFiles" could then be introduced in the section "Main".
I think it's easier to apply changes after than before processing portable registry keys or portable files. As a matter of fact "Before" processing couldn't be applied if someone uses REGKEYS instead of USEREGKEYSFILE.
What's your opinon about this ? How do you suggest to deal with path updates within portable registry keys and portable file entries ?
I've just discovered PortaLaunch. It seems that a lot of enhancements have been added to your original PAT. It would be great to share your ideas and have only one template instead of creating several ones.
My template doesn't have all the functionality of Klonk's but I added a function to change the drive letter to the portable drive letter.
It should work for any file that is stored as text.
Application Launcher Template
-----------------------------------------------------------------------------------------------
Because they stand on a wall and say nothing is going to hurt you tonight. Not on my watch.
"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)
Ar you changing each driver letter you find or only specfifc ones?
It will search for every instance of a drive letter and change it.
-----------------------------------------------------------------------------------------------
Because they stand on a wall and say nothing is going to hurt you tonight. Not on my watch.
"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)
if only some sign should be replaced, maybe %%PATdrive%% and/or %%PATAppPath%% (maybe also %%PATDataPath%%. But where should it be replaced? In registry keys? in some configuration files? How to determine which configuration files to use? Of course they will have to be modified before start of the application. On the one hand it would be good to modify them when they are copied to the host thus not doing to much write actions on the thumbdrive. On the other hand some apps could be set to access the files on the thumbdrive without need to copy them to the hosts harddrive.
Shouldn't also some envornment variable be set (some applications could use environment variables in their settings which would again help making the application portable
Should this replacement happen automatically? But then not everey drive letter should be replaced just specific ones. But then also the last used drive letter has to be saved somewhere.
What do you think?
about that myself. But there should be several values that might be necessary:
At least the driveletter and the path to the application.
But which coding to use to make sure it is not used already. For example %drive% might be used by an application already.
Regarding PortaLaunch: We have slightly different goals. With PortaLaunch all settings are done within an INI file, while in this template all settings are done within the source code. The only big difference I see is the loading of DLLs which I did not implement. Is it needed? Something else I forgot.
BTW: I heard rumours that john is currently creating a launcher that works with INI files (similar to PortaLaunch). Maybe also some other stuff changes.
But nevertheless: If you think a function would be nice (without bloating the template too much) please tell me.
I started with NSIS last week and found your template v1.4. Little did I know v2.0 was the latest! Either way I'm up to speed now, and I've found a few minor bugs. In it's default state, v2.0 throws 2 warnings and an error when compiling.
1. The variable ${EXEPARMS} on appx line 641 in the RunApp function is not defined. I just commented out that line and the preceding one.
2. The label CleanRegCleanUp on appx line 742 is not used. This is because if no regfile is used for the regkeys (ie listing reg keys in the source) then this label is never called. I added a superfluous Goto two lines above just to avoid the warning.
3. In the InitINI function, there is a jump to CheckAppsINI (I think) at appx line 232, and the label does not exist. It looks like there are 3 INI file directory locations you are checking in v2.0. In v1.4 there were about 5 maybe? So I don't know if you left these out on purpose and forgot to update the Goto, or what. Either way I just jumped to InitINIEnd to get rid of the error.
As for suggestions -
1. Reinstate a Sleep 50 command after, at least, any ${registry::SaveKey}. I had a problem where the reg keys were not deleted becuase they were still open for saving from the previous command. To be safe, I added Sleep 50 after any registry operation.
2. Consider in the InitReg function deleting ALL reg keys once they have been backed up, and not relying solely on the imported Registry.reg file to do it. The case for this I found was when having a locally installed version of the program and then running the portable version. In some cases regsitry entries that were only used by the native installation were making their way into my portable reg files becuase they were not being deleted first. Case in point is Eraser 5.82. I have some scripts where I call eraserl.exe to do a final cleanup, and it creates just the main HKCU key. On a computer where I had the full version of the program installed, ALL the HKCU keys and values were being migrated back to my portable reg files. I'm picky about my settings being intermingled, so I edited the script to delete all keys after they are backed up...so I can start the portable app from a clean slate.
Great job on this template, really. It was a great help to start learning NSIS and I don't know what I would have done without it at. The learning curve would have been really steep. Keep up the good work!
Thanks for the update to 2.0, I have updated my portableapp to use this template and seems to be working OK...
My suggestion:
Include the following line in the template (probably as an option part of runtime switches):
RequestExecutionLevel user
This helps with apps that do not require admin priveleges, but are being run under a Vista Standard account with UAC turned on. If I didn't put this line in, then Vista would always prompt me for admin password, even though admin access is not required for the app (only makes changes to HKCU).
Thanks again.
I have no VISTA thus I did not run into that. I'll add it.
BTW: I uploaded version 2.1.
I'll fix them and release a bugfixed version. Regarding the InitReg Function:
Normally If you specify a main key everything should be deleted within that main registry key.
Nevertheless, I'll add an option at the configuration part, where you can specify whether to delete the registry keys.
I'm new to PortableApps. It's a great idea and I love what is currently available. I'd like to start developing, but do not know what "helper apps" are available to monitor which files, folders, and registry keys are generated.
Thanks a lot!
I use Regmon and Filemon (Sysinternals), any registry app that can take snapshots and compare them like Registry Workshop, and good old search. This is good for most apps that don't install drivers etc. Some people will suggest an uninstaller program like TotalUninstall (I think?) that can monitor an entire installation and tell you what went where. I don't tend to use it cause I'm not so interested in what is done during installation, as compared to what is done at runtime or while configuring options, ie some reg keys and stuff may be created by the installer but not by the program if just extracted and run, and some reg keys are created by the program at runtime/configuration and not by the installer.
In version 2.1, line 646 is throwing out errors if EXEPARMS(commandline default parameters) is not defined. To fixed the error, I replaced lines 645, 646 with:
fixed it
"2. You monitor which files, folders, and registry keys are generated. (There are several helper apps for that task)."
What are those? And where are they found. Thanks!
BTW: This s really helpful! A template is always good.
Whats with the Java stuff? Thats optional right?
Also one that I don't understand at all is the delete stuff? Whats that for?
I am trying to make a portable version of debugview (from sysinternals). The problem I've got is that debugview writes in 2 places in the registry and I think this is causing my "Registry.reg" file to get deleted for some reason.
I have made a portable version of Tcpview, Portmon and ProcessExplorer and these all run fine (They all only write to one area in the registry).
What I have done is export the debugview registry settings to Registry.reg and also added the dbgview reg settings (second place of reg settings) to this reg file. When I run my portable version of debugview it runs correct the first time (I can also see regisytrybackup.reg in the data folder) but when I shut it down it seems to restore the backed up registry settings but then deletes both reg files in my data directory.
Could someone help me with this please? Has anyone else managed to get multiple reg settings to work?
Cheers Rochey
Do you use the REGFILES section of the template, or the REGKEYS section? I've had no problem with multiple keys using the REGKEYS section. Maybe be a bit more specific as to what keys you're trying to backup/restore. As far as I'm aware, it's just HKCU\Software\Sysinternals\DbgView and HKCU\Software\Sysinternals\DebugView
I'm using the Regfiles section with both the debugview keys that you have said. See with Tcpview, for example, I was using the Regfiles section but it only had "HKCU\software\sysinternals\tcpview" to write when I ran the portable version of it.
I am just wondering whether using Regfiles with multiple keys (in debugviews case 2 keys) doesn't work. Don't suppose you could try and do it to see if you get the same problems, wraithdu?
If not don't suppose you could let me have your version of portable debugview? (it sounds like you have a version already and why re-invent the wheel!)
I don't have a portable version of it actually, I mean it would only take 2 seconds to make it using the template. Why don't you try moving those 2 keys to the REGKEYS section. I've never had a problem doing it that way, and I have used over 8 keys before.
If you still have a problem, I'll give it a try though.
EDIT -
According to the template, the old Registry.reg file is deleted, then a new one is created on shutdown. I don't think the new regfile is being created.
Try changing the ${WordFind} line in the RegFileToStack function to read "+1" instead of "+01". See if that works.
I am starting to get frustrated with this now!!(lol)
wraithdu, I tried using the regkeys section and the first time I ran portabledebugview my settings were created in Registry.reg (I was getting ready to kiss you! ha!). Then when I ran it a second time I had to create my settings again, so I checked the Registry.reg file it created and found that all the data had gone.
I have attached my user settings from the template, could you look at it and tell me is you think this is correct? If it is then I have know idea why it doesn't work
for me. I look forward to hearing from you.
Rochey
; ##########################################################################
; ----- Basic informations
!define AUTHOR "Rochey" ; your name
!define APP "DebugView" ; insert application name, e.g. "TestApp"
!define VER "4.64.0.0" ; insert version of launcher
!define EXE "dbgview.exe" ; insert program exe name, e.g. "testapp.exe"
;!define EXEPARMS "" ; insert some default Parameters
; ----- Application specific stuff
; insert regkeys to use separated by "||", comment out, when not used,
; e.g. HKCU\Software
!define REGKEYS "HKCU\Software\Sysinternals\debugview||HKCU\Software\Sysinternals\dbgview"
; If a file "Registry.reg" within the data directory is found then it is read
; and all parent registry keys are processed as if they'd have been set within
; REGKEYS
; !define USEREGKEYSFILE "TRUE"
; delete alle defined registry keys before own ones are applied (during Init)
!define DELETEREGKEYS "TRUE"
; insert settings files to use separated by "||" as stored on the host
; computer, e.g. "$WINDIR\TEST.INI", comment out, when not used
; !define SETTINGSFILES ""
; insert settings directories to use separated by "||" as stored on the host
; computer, e.g. "$PROFILE\TEST", comment out, when not used
; !define SETTINGSDIRS ""
; Require local administrator rights to run the launcher, necessary when
; writing to e.g. HKLM registry key. If not required comment out
!define ADMINREQUIRED "TRUE"
; Redirect Userprofile folder, comment out when your application calls other
; programs, i.e. to disable automatic redirection. Default value "TRUE".
; !define REDIRECTUSERPROFILE "TRUE"
; When "TRUE" a launcher is created that contains the sources and copies them
; into the appropriate folder if they do not exist yet.
; !define INSTALLSOURCES "TRUE"
; define which GTK version should be used, e.g. 2.0
; !define USEGTKVERSION ""
; define which JAVA version should be used, e.g. 1.6.0_01
; !define USEJAVAVERSION ""
; ----- Normally no need to change anything here
; format of portable name (dirs and filenames)
!define PNAME "${App}Portable"
; comment this line out when default icon should be used
!define ICON "${PNAME}.ico"
; comment this line out when no splashscreen image should be used
; !define SPLASHIMAGE "${PNAME}.jpg"
; could be changed when settings for multiple applications should be stored in
; one INI file
; !define INI "${PNAME}.ini"
I figured it out. In the original template, when backing up the portabe registry in the CleanReg function, the keys are backed up with the switch /D=2 which means that in the regfile, before a key is restored it is deleted -
[-HKCU\Software\Sysinternals\DbgView]
This is somehow messing up the importing of this file when !DELETEREGKEYS=TRUE because the keys are already deleted.
Remove /D=2 from the ${registry::SaveKey} line in the CleanReg section, and that should clear everything up. About line 763.
Cheers for your help wraithdu but it still doesn't work with your advice. I think that I am going to have to dig out reg rapper. From what I remember it stores the separate reg keys in different reg files. Plus it's getting late and I'm getting very
frustrated!
I still can't believe that I seem to be the only one with this problem (so I keep thinking that I'm doing something wrong). never mind.
Again cheers for your help wraithdu.
Rochey
Pages