I am looking to create a custom.nsh file to handle some things in a launcher. I Know that he PortableApps Launcher has part of the feature but I need to disable it for speed sake. Here is what I have so far but does not seem to accomplish what I am wanting.
!macro CustomCodePost ${Segment[Unload]} # The following attempt at a custom code was created by Patrick Powell # Who is a PorableApps Developer whose current list of apps is located at https://portableapps.com/node/30620 # This code was created in an attempt to clean up files after disabling CleanTemp in the PortableApps Launcher.ini file # for rednotebook. This hopes to help speed up the launcher for the app as well as to reduce clutter of the Data Directory ${If} ${FileExists} "$INSTDIR\Data\rn-tmp*.html " #looks for files Delete "$INSTDIR\Data\rn-tmp*.html" #Deletes all files which cleans the clutter CopyFiles /SILENT "$INSTDIR\App\DefaultData\rn-tmp*.html "$INSTDIR\Data" #replaces files with the Default files #Copies the default files back to data dir ${EndIf} !macroend
I know that the comments are unneeded.
Basically on exit I want to delete some files then move some from a directory to another one. So what am I missing/doing wrong?
Never use $INSTDIR. It has no meaning in PAL. $EXEDIR is what you meant, but you shouldn't use $EXEDIR\Data here either; $DataDirectory is what you need. Same for $EXEDIR\App—use $AppDirectory.
I am a Christian and a developer and moderator here.
“A soft answer turns away wrath, but a harsh word stirs up anger.” – Proverbs 15:1
Remove the [ ] Brackets.
Also, do you need to copy over the DefaultData temp files? I thought they were recreated by every launch anyway.
Forgot that about the default data. As for the [Brackets] do you mean in the Segment are?
Also should I be doing this in Post hook or Unload hook...told you I was WAY a newbie to NSIS Was trying to do it myself with out having to always bother others to do it for me
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” Dr. Seuss
Re: defaultdata - to clarify, I meant why have the temp files in default at all? I understood that there were recreated by the base app every run. But that could be me misunderstanding you.
For the custom file you have above, it should be ${SegmentUnload}
I would keep it in unload, but that's just me. Chris might have a better suggestion.
It's not a bad start at the custom stuff. I started just like you, not long ago.
[EDIT] Also, remove the line "!macro CustomCodePost"
Launcher will not generate gives me following in log file (I only am showing the errors
And this is using the remove brackets as Gord said
So Line 1 is now:
${SegmentUnload}
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” Dr. Seuss
Line 1 should be
${SegmentFile}
Line 2 is empty
Start with the rest at line 3
to not like the * variable. Do I need to define what it does the variable I mean?
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” Dr. Seuss
At present, your code should be roughly the following:
I am a Christian and a developer and moderator here.
“A soft answer turns away wrath, but a harsh word stirs up anger.” – Proverbs 15:1
But yours works mine does not....sort of. The copy file is not writing htem back to data directory which is ok I guess as Gord pointed out the files w ill automatically get written back on launch anyways
Now I need to figure where my error was Knowing me I am sure I typo somewhere
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” Dr. Seuss
Please add tag of TYPO KING
Apparently I had some sort of typo going on.
I removed the copy as it was not needed...FYI here is completed and WORKING code
To think only took me 3 hours to write a 5 minute code
BTW I was using the PortableApp Launcher manual, the NSIS manual and Google trying to resolve this myself.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” Dr. Seuss