You are here

Custom Code with Installer

19 posts / 0 new
Last post
prapper
Offline
Last seen: 3 years 10 months ago
Developer
Joined: 2008-01-24 17:01
Custom Code with Installer

OK, so I've got "PortableApps.comInstallerCustom.nsh" in the Other\Source directory and it contains -

!macro CustomCodePostInstall
MessageBox MB_OK|MB_ICONEXCLAMATION `hello`
!macroend

but I can't figure out why I'm not getting anything.

John T. Haller
John T. Haller's picture
Offline
Last seen: 2 hours 58 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Fixed in 0.91.3

It was a bug in 0.91.2. It's fixed in 0.91.3.

Sometimes, the impossible can become possible, if you're awesome!

prapper
Offline
Last seen: 3 years 10 months ago
Developer
Joined: 2008-01-24 17:01
Wow, I found two bugs in one

Wow, I found two bugs in one day, I must be on a roll... Smile and you guys fixed them within a couple of hours. That's what I love about this open source stuff... Smile

Nice one(s)...

prapper
Offline
Last seen: 3 years 10 months ago
Developer
Joined: 2008-01-24 17:01
I still can't get it to work

I still can't get it to work though...

???

xuesheng
Offline
Last seen: 11 months 1 week ago
Joined: 2008-03-21 15:34
Is this a plugin installer?

I tried adding custom code to a plugin installer and none of it gets executed when I run it.

prapper
Offline
Last seen: 3 years 10 months ago
Developer
Joined: 2008-01-24 17:01
Yes it is... or was, rather

Yes it is... or was, rather Smile

prapper
Offline
Last seen: 3 years 10 months ago
Developer
Joined: 2008-01-24 17:01
Is there any news on whether

Is there any news on whether this has been confirmed or not? I still can't get it to run with 0.91.4.

John T. Haller
John T. Haller's picture
Offline
Last seen: 2 hours 58 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
wfm

It works for me. Remember you need to name your custom code as PortableApps.comInstallerPluginCustom.nsh.

Sometimes, the impossible can become possible, if you're awesome!

prapper
Offline
Last seen: 3 years 10 months ago
Developer
Joined: 2008-01-24 17:01
Hmm... yes, I realised that

Hmm... yes, I realised that shortly after the inital post. I've just tried again, filename copied & pasted from your reply. The installer compiles, installs and downloads the files all fine (again) but still I don't get the custom code. Both files ("plugininstaller.ini" & "PortableApps.comInstallerPluginCustom.nsh" in Other\Source.

I am missing something here...

John T. Haller
John T. Haller's picture
Offline
Last seen: 2 hours 58 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Right Macros

You sure you have the proper macros defined?

Sometimes, the impossible can become possible, if you're awesome!

prapper
Offline
Last seen: 3 years 10 months ago
Developer
Joined: 2008-01-24 17:01
Well I'm still using what's

Well I'm still using what's in the initial post at the moment plus the NSIS code required to copy then delete the files straight afterwards but I'm not even seeing the messagebox.

prapper
Offline
Last seen: 3 years 10 months ago
Developer
Joined: 2008-01-24 17:01
An update. I've got it

An update. I've got it running. It looks like there was something wrong with my nsh file as I copied all the code into a new file then resaved and that's sorted it out. But...

I'm using this...

CopyFiles /SILENT "App\AppName\DirA\*.*" "App\AppName\DirB"
RMDir /r "App\AppName\DirA"

The are 64 files in DirA but only the first 33 are being copied. I've tried altering the code to just move the 34th file to see if it's stumbling there for some reason but it works fine and I don't want to just rename DirB to DirA, in case there are going to be other files in DirA, so it has to be a copy then delete. Also, after they've been copied over, all the long filenames have been truncated to 8.3.

I haven't tried listing out all 64 files yet, for obvious reasons!

And after all that, DirA is not being removed.

Apologies for dragging this one out, perhaps this isn't an installer issue after all but I'm more baffled now than I was before Smile Hopefully somebody can point out the obvious mistake I'm making.

xuesheng
Offline
Last seen: 11 months 1 week ago
Joined: 2008-03-21 15:34
Have you tried this?
CopyFiles /SILENT "App\AppName\DirA\*.*" "App\AppName\DirB\"

I had a quick grep through my NSIS code and it seems that CopyFiles likes a trailing slash in the destination when copying files. I also use the /FILESONLY flag if I only want files copied

prapper
Offline
Last seen: 3 years 10 months ago
Developer
Joined: 2008-01-24 17:01
Still no go I'm afraid.

Still no go I'm afraid. Thanks for the suggestions though.

prapper
Offline
Last seen: 3 years 10 months ago
Developer
Joined: 2008-01-24 17:01
OK, so I bit the bullet and

OK, so I bit the bullet and listed out all the files and they're all moved successfully now, filenames intact. However, I still can't delete the remaining empty directory.

Is there some reason why this...

RMDir /r "App\AppName\DirA"

wouldn't work in "PortableApps.comInstallerPluginCustom.nsh"?

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 9 years 6 months ago
Joined: 2007-04-15 21:08
ALWAYS absolute paths

In NSIS installers, you ALWAYS need absolute paths - otherwise enter erratic behaviour. This'll be why your CopyFiles goes weird as well. What you want is $INSTDIR\App\AppName\Dir[A|B] etc. Also look at Rename (I don't know if it's what you want, you may already have files in DirB; if you're just wanting to rename it though that's the way to go). As for a trailing slash, it's only useful in clarifying what a thing is. If the directory already exists, there'll be no problem with it.

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

prapper
Offline
Last seen: 3 years 10 months ago
Developer
Joined: 2008-01-24 17:01
Thanks Chris, most helpful as

Thanks Chris, most helpful as always, that's sorted it out.

xuesheng
Offline
Last seen: 11 months 1 week ago
Joined: 2008-03-21 15:34
CustomCodeOptionalCleanup runs at the wrong time

According to the 0.91 (2009-06-11) specification CustomCodePreInstall is run before installation, CustomCodePostInstall is run after installation and CustomCodeOptionalCleanup is run after installation if the optional section of an installer is not selected. This is not how it works in Installer 0.91.3 - CustomCodeOptionalCleanup appears to be run before the installer does anything else.

I set each macro to display a message box showing the appropriate macro name:

With the optional component selected:

existing installation files removed
CustomCodePreInstall macro executed
main installation files installed
CustomCodePostInstall macro executed
optional files installed
installer finished

With the optional component NOT selected:

CustomCodeOptionalCleanup macro executed
existing installation files removed
CustomCodePreInstall macro executed
main installation files installed
CustomCodePostInstall macro executed
installer finished

John T. Haller
John T. Haller's picture
Offline
Last seen: 2 hours 58 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Confirmed

I've confirmed this, but I haven't decided whether to change the spec or the installer. Ideally, it shouldn't matter as it's really designed for upgrades.

Sometimes, the impossible can become possible, if you're awesome!

Log in or register to post comments