Archive: Possible macro bug?


Possible macro bug?
I have written a macro to unregister my activex exe's and then delete them. However there seems to be a problem. where the macro is called but the delete line is never reached: This is the macro:

!macro UnRegActiveXEXEDel sPathAndApp

Exec '"${sPathAndApp}" /unregserver'
IfErrors 0 +2
DetailPrint "Error UnRegistering ${sPathAndApp}"

Delete "${sPathAndApp}"

!macroend


I then call it using:
!insertmacro UnRegActiveXEXEDel "$INSTDIR\VCTTools\Type003\AirBag.exe"

But in the uninstall list box only the 'exec' line is called and therefore displayed. If I change the IfErrors line to 0 +1 then the Error message is always displayed so the code is passing through.

Can anyone shed any light on what might be wrong, or is it a bug?

Thanks


Works fine for me. It is possible no message ie being displayed because the file can not be found.

BTW, you are missing a ClearErrors instruction before Exec.


Weeerrll...so basically your question is more to do with the delete command than the macro? You might want to be clever and try using the /REBOOTOK flag like so:


Delete /REBOOTOK "${sPathAndApp}"


and then either waiting for the installer to finish (in which case if the file needs to be deleted on reboot because it is locked then the system will prompt you) or (in production) use this to check whether it needs to be rebooted and flash up an appropriate warning message. Or something.

Oh er, I assume you've tried like MessageBox MB_OK "${sPathAndApp}" to check the file exists that way. You can even use the built-in IfFileExists command. Good, eh?


To try and answer in order. I currently have a whole host of commands to unregister the exe's and then a load more to delete them:

Exec '"$INSTDIR\VCTTools\Type003\AirBag.exe" /unregserver'
.
.
.
Exec '"$INSTDIR\VCTTools\Type003\StartNisn.exe" /unregserver'

Delete "$INSTDIR\VCTTools\Type003\AirBag.exe"
.
.
.
Delete "$INSTDIR\VCTTools\Type003\StartNisn.exe"

This as it stands works ok, but what I wanted to do was combine these two into one macro so that if any changes need to be made then it is in one place instead of two. When I used the macro, the delete doesn't work. So the answer to the file exists question is yes it does exist.


Ok, so it is something to do with the order in which things happen? Whereas before you were unregistering all before deleting, now you are deleting some before others are unregistered. Could it be that still-registered exes are preventing the deletion of a newly-unregistered exe?

If this doesn't help you could do something like have a macro which unregisters and then places the file&path on the stack, with say a $counter variable, then when all of the unregistering has been done simply call a function which unwinds the stack $counter number of times, deleting each thing it finds on it.

Or something...

BTW how is Stoke? You aren't a million miles away from me :)


Try using ExecWait instead of Exec so NSIS will wait until the executable finishes.


Oh heh it could just be that, lol!


Having said that, that's quite alot slower than all of the unregs being performed with Exec (i.e. slightly more in parallel), and perhaps just having the final unreg performed with ExecWait (assuming roughly standard time taken to unreg).

ExecWaiting all of them will slow it down cos it's being done in strict serial.


ExecWait seems to be the answer to my prayers. I must have still been unregistering it when I tried to delete it and so failed - no message is displayed in the list box to say it has even been called though which is what confused me!

Thanks for the help.

BTW I'm don't mind that the uninstall is slow - that is a small price to pay!


You could always print a message in the InstFiles window with DetailPrint...

-Stu