You are here

Portable Application Template 1.5 Suggestions

31 posts / 0 new
Last post
SmithTech
SmithTech's picture
Offline
Last seen: 2 years 7 months ago
Developer
Joined: 2006-11-24 18:06
Portable Application Template 1.5 Suggestions

First let me say thanks SOOO much for making the 1.4 template, I have used it to create several launchers.
I have a few suggestions/requests for ver 1.5
Instead of copying the users current reg and folders etc to the usb drive, can they be renamed to file.ext.portbak, folder.portbak, and regkey.portbak or something similiar? this would be a lot faster than copying them to the flash drive.

This next request is a significant one I realize, but I think it would really be helpful to "intermediate" users who want to customize the script.
Could you change the "layout" of the template to the following...

Section "Main"
	Call Init ; Absolute first things to do, current Init Function
	Call InitReg ; Backup current reg, apply portable reg
	Call InitFolders ; rename current folders, apply portable folders
	Call InitFiles ; rename current files, apply portable files
	Call InitIni ; apply ini settings
	Call InitApp ; run app
	Call CleanFiles ; copy portable files, delete portable files, rename original files
	Call CleanFolders ; copy portable folders, delete portable folders, rename original folders
	Call CleanReg ; copy reg, restore original reg
	Call Clean ; Absolute last things to do, current Cleanup Function
SectionEnd

Function Init
FunctionEnd

Function InitReg
FunctionEnd

Function InitFolders
FunctionEnd

Function InitFiles
FunctionEnd

Function InitIni
FunctionEnd

Function InitApp
FunctionEnd

Function CleanFiles
FunctionEnd

Function CleanFolders
FunctionEnd

Function CleanReg
FunctionEnd

Function Clean
FunctionEnd

I realise that combining the pre and post functions is probably a better way of doing things. But seperating it out will help "intermediate" users follow the logic and learn NSIS.
Beginners aren't going to do more than change the very top section with the Constants, and "Advanced" users would really be able to fully write their own scripts. But "Intermediate" users I think would be better able to follow the logic and make more customizations if it were formated this way.

Thanks In Advance.

Simeon
Simeon's picture
Offline
Last seen: 10 years 1 month ago
DeveloperTranslator
Joined: 2006-09-25 15:15
Nice idea

It makes everything even clearer than it has been in 1.4

"I believe that a scientist looking at nonscientific problems is just as dumb as the next guy." - Richard P. Feynman

"What about Love?" - "Overrated. Biochemically no different than eating large quantities of chocolate." - Al Pacino in The Devils Advocate

Klonk
Offline
Last seen: 12 years 7 months ago
Joined: 2006-04-21 03:08
OK,

I'll think about that.
So you are specifically talking about the function "Doaction", right?

For a normal user who want's to create a portable application, everything that should be changed are the constants at the beginning (maybe I could make this clearer).

Maybe moving the function "Doaction" into an external file would also help?

BTW: you may add it to NSIS portable if you like..

Klonk
Offline
Last seen: 12 years 7 months ago
Joined: 2006-04-21 03:08
Do you think

that additional comments are necessary to make usage more clear??

Klonk
Offline
Last seen: 12 years 7 months ago
Joined: 2006-04-21 03:08
Your first suggestion

is a good idea I'll implement that.

SmithTech
SmithTech's picture
Offline
Last seen: 2 years 7 months ago
Developer
Joined: 2006-11-24 18:06
Top to Bottom Logic

I think the DoAction, and Main sections, and maybe the InitVariables moved to the Init section mentioned.
I know the "average" user will just need to change the constants etc. at the very beginning.
This change is more for "intermediate" users who would want to add or change functionality, make it easier for them to follow the logic flow.
I've made several launcher using your template, but am at a point where I would like to add additional functionality. I'm not really familiar with NSIS and would have to figure out how to do it. But following the logic flow in your template makes it more difficult.
I realize the DoAction is reusing code for the backup and restore steps which is a more "proper" way to do it. But again for an "intermediate" user it would make customizing the script easier is the logic was top to bottom rather than modularizing for code reuse. If that makes sense.

Just to give you some ideas of what I want to do.
In one launcher I need to do a sting replace of the drive letter in some registry entries, but the reg file is in hex so I need to use a different plugin.
In another launcher I want to have it rename the settings directory but NOT copy the flash drive settings. Then at the end I still want it to copy any changes from the settings directory and restore the original.
It would be much easier for me (and I assume others) to do these kinds of customizations if the logic flow was top to bottom (old style top down programming)

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)

Klonk
Offline
Last seen: 12 years 7 months ago
Joined: 2006-04-21 03:08
The order will have to be a little bit different

but I do my best to modularize it.
I'll leave a message when I'm finished for the first beta test.

SmithTech
SmithTech's picture
Offline
Last seen: 2 years 7 months ago
Developer
Joined: 2006-11-24 18:06
cool, thanks a lot, it is

cool, thanks a lot, it is much appreciated.

-----------------------------------------------------------------------------------------------
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)

Klonk
Offline
Last seen: 12 years 7 months ago
Joined: 2006-04-21 03:08
Finished, please test the beta

I finished the completet rewrite. Please consider this version as beta, as I'm not sure whether I forgot something.

So please test it.

And (more important) tell me your opinion about the structure now. Is it clear how it works now? Do you think it is easily extendable?

Download the 1.5 Beta version of the template here:
http://www.loncarek.de/downloads/ApplicationPortableTemplate_1.5.nsi

Thanks for your help.

Future:
I'm currently thinking of a major enhancement (for version 1.6, if I ever get it working). But first this version should be approved and work.

SmithTech
SmithTech's picture
Offline
Last seen: 2 years 7 months ago
Developer
Joined: 2006-11-24 18:06
Just a quick read through

I did a quick read through, it looks good.
I will test it on several launcher, I can redo the ones I have done already.
I have only one "issue". If the backup directory exists, you delete it. I understand the rename won't work if it exists, but if it does exist, this means that a previous run didn't complete properly and the current directory is most likely the settings from the last portable run. By deleting the backup directory you are most likely deleting the original settings and renaming the previous portable files as the backup. Not sure how best to actually handle this "issue", possibly a prompt asking the user what to do.
In 99% of cases this shouldn't actually be an issue as the backup directory shouldn't exist, but in the event that it does, maybe the default action should be to delete the current directory instead and keep the old backup.
Anyone else have ideas on this?

-----------------------------------------------------------------------------------------------
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)

Simeon
Simeon's picture
Offline
Last seen: 10 years 1 month ago
DeveloperTranslator
Joined: 2006-09-25 15:15
Maybe

make sure it is empty at the end of the Launcher and clean it if its not.
"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

Klonk
Offline
Last seen: 12 years 7 months ago
Joined: 2006-04-21 03:08
Normally it should be deleted anyway.

So this could only happen, when the launcher itself is interrupted (killed)for any reason.

Klonk
Offline
Last seen: 12 years 7 months ago
Joined: 2006-04-21 03:08
Yes

you're right.
In such a case it is more important to keep the original data and restore the last backup. The worst case that might happen then is that some private portable settings are lost.

So what would be the best thing to do? Some ideas:
1. Delete Backup
2. simply copy portable data from media, leave backup alone, restore data on exit of launcher
3. compare what has changed, backup portable data to media
4. restore backup and start from beginning (i.e. delete portable data on the host computer)

"1" is the way it is done currently. "2" and "4" are easily to implement. "3" is quite hard to implement.
Regarding the propability of such a case, I would not do "3".

So what do you think is best "1", "2", or "4"?

SmithTech
SmithTech's picture
Offline
Last seen: 2 years 7 months ago
Developer
Joined: 2006-11-24 18:06
I think option 2 would be

I think option 2 would be the best way to go.
How difficult would it be to give the user the option of 1,2, or 4?
Realistically, a user could manually compare the files while the prompt is waiting for an answer. Possibly a 4th option to do nothing and just exit the launcher and not launch the app so the user can manually assess the situation then relaunch the launcher.
Or even better make that the default, just do a popup window that says something like "Backup files already exist, please fix the problem and relaunch the app" Maybe write to a log file what files need to be addressed so the user knows where to look.
Just a suggestion, I don't know how difficult it would be.

-----------------------------------------------------------------------------------------------
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)

Klonk
Offline
Last seen: 12 years 7 months ago
Joined: 2006-04-21 03:08
The decision is just a comparison

of effort vs real need as this might not happen too often.
A message wold be easiest. Maybe I could create a message yes/no/cancel with a text maybe like this:

Backup file/folder already exist. Do you want to keep it?
YES = simple copy portable data, keep backup of original files
NO = delete backup file/folder, create new backup of actual files
CANCEL = exit launcher, and fix problem manually

option 4 is basically the same in the end as option 2. So what do you think about that?

BTW: Please download new beta (dated 2007/04/19), The currently discussed imporvement is not yet implemented.

SmithTech
SmithTech's picture
Offline
Last seen: 2 years 7 months ago
Developer
Joined: 2006-11-24 18:06
If the Yes,No,Cancel is

If the Yes,No,Cancel is doable then I think that would definitely be the way to go.
If cancel is clicked, maybe write the folder etc. names t a log file and open it automatically so the user knows what folders, etc. to look at.

-----------------------------------------------------------------------------------------------
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)

SmithTech
SmithTech's picture
Offline
Last seen: 2 years 7 months ago
Developer
Joined: 2006-11-24 18:06
I redid 3 apps previously

I redid 3 apps previously done with the 1.4 template.
the 1.5 template doesn't appear to be deleting the reg entries when the app closes.

-----------------------------------------------------------------------------------------------
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)

Klonk
Offline
Last seen: 12 years 7 months ago
Joined: 2006-04-21 03:08
Did you

check whether a backup file existed before?

Is the restore done correctly?

Maybe you could try in the function to increase the value at line 512 to "Sleep 100"
This might help as saving the key might take some time.

So I guess: the key is deleted too early after saving it.

Please try this and report, so I could add this to the template. Thanks.

And maybe also in line 524 (when exchanging more than a single registry key)

I'll try to test it here also.

SmithTech
SmithTech's picture
Offline
Last seen: 2 years 7 months ago
Developer
Joined: 2006-11-24 18:06
The apps I tried it with

The apps I tried it with only have registry entries, no files to deal with.
The registry entries are applied ok, but when the launcher exits its not deleting the registry entries. I will try your suggestion today if I can.
Just a side note, the comments at the bottom are giving warning errors.
I think its because of the \
Not a big deal there only warnings, but a newbie might not understand that.
Once the template is tested and confirmed working properly, maybe the comments could be moved to a readme.txt and added to a zip file.

-----------------------------------------------------------------------------------------------
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)

Klonk
Offline
Last seen: 12 years 7 months ago
Joined: 2006-04-21 03:08
Interesting,

I don't get any warnings....

SmithTech
SmithTech's picture
Offline
Last seen: 2 years 7 months ago
Developer
Joined: 2006-11-24 18:06
What version of NSIS are you

What version of NSIS are you using?

-----------------------------------------------------------------------------------------------
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)

Klonk
Offline
Last seen: 12 years 7 months ago
Joined: 2006-04-21 03:08
I use

version 2.20

Klonk
Offline
Last seen: 12 years 7 months ago
Joined: 2006-04-21 03:08
tried with 2.24

and found the problem, will be fixed in final / next beta.

Klonk
Offline
Last seen: 12 years 7 months ago
Joined: 2006-04-21 03:08
Please download again

as I found several bugs in the source. (Please change only the constants as there are several bugfixes)
Now they are fixed and it should work now.

Please check again and report. Thanks.

SmithTech
SmithTech's picture
Offline
Last seen: 2 years 7 months ago
Developer
Joined: 2006-11-24 18:06
ok, I created a test app

ok, I created a test app with test files and folders and test registry.
The files and folders aren't backed up.
If registry entry doesn't exist and data\Registry\RegistryKey1.reg exists it applies and deletes it correctly.
If registry entry exists and data\Registry\RegistryKey1.reg exists it backs up , applies, and restores correctly.
If registry entry exists but data\Registry\RegistryKey1.reg doesn't exist, it backs up and restores entries correctly but doesn not save changes to registry made while it was running.
If neither exist, entries added during application run are not saved.

-----------------------------------------------------------------------------------------------
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)

Klonk
Offline
Last seen: 12 years 7 months ago
Joined: 2006-04-21 03:08
I tested it here

If registry entry exists but data\Registry\RegistryKey1.reg doesn't exist, it backs up and restores entries correctly but doesn not save changes to registry made while it was running.
-> Here it is saved correctly..

If neither exist, entries added during application run are not saved.
-> Here it is saved correctly..

In the last beta I removed some Sleep commands in the CleanReg. I added them now again, please try again with the new beta I just uploaded. (file size 39933 bytes)

Please do this registry test again on your system.

I haven't included this YesNoCancel thing yet. (I'll do in th next beta when the above works now for you.

SmithTech
SmithTech's picture
Offline
Last seen: 2 years 7 months ago
Developer
Joined: 2006-11-24 18:06
DataDirectory not set in ini file

I tried to remake one of the launchers I previously did with the 1.4 template.
All I did was edit the constants, copied and pasted the values from the previous template.
It compiles fine, but when I run the exe I get "DataDirectory" was not set in INI file. Please check your configuration.
As I said all I did was copy and paste the exact constant values from the old 1.4 template to the 1.5 template.
I can't post the entire script here but I can email it to you if need be.

-----------------------------------------------------------------------------------------------
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)

Klonk
Offline
Last seen: 12 years 7 months ago
Joined: 2006-04-21 03:08
You use an

INI file, do you?
I found the problem and fixed it. I haven'T checked anything else yet.

Klonk
Offline
Last seen: 12 years 7 months ago
Joined: 2006-04-21 03:08
New 1.5 RC, dated 2007/04/23

changes:
- fixed warnings on comment part at the end
- added YESNOCANCEL message for existing backup files/folders

Please tell me whether registry backup now works for you.

I think I'll call this version a Release Candidate.

SmithTech
SmithTech's picture
Offline
Last seen: 2 years 7 months ago
Developer
Joined: 2006-11-24 18:06
I found the problem.

If the data\registry folder doesn't exist, it doesn't create it, so it fails to write the backup RegKey1.reg file.
If the data\registry folder exists, everything works as expected.
I haven't tested the new Yes,No, Cancel yet.

-----------------------------------------------------------------------------------------------
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)

Klonk
Offline
Last seen: 12 years 7 months ago
Joined: 2006-04-21 03:08
Thanks,

I added the creation of that directory if it does not exist before.
A new 1.5RC is available (dated 2007/04/26)

Log in or register to post comments