I guess there is not a such option as, if a reboot is occuring, all the programs are being closed or killed.
You are thinking of installing a program when the computer is going to be shut down (or restarted), which makes a bit of no sense to me.
Anyway, there should be a way to bind the execution of some script to a shutdown event.
This URL shows how to get such kind of events : http://blogs.technet.com/b/heyscriptingguy/archive/2010/10/01/quick-hits-friday-the-scripting-guys-respond-to-a-bunch-of-questions-10-1-10.aspx
I think you may be able to cancel the shutdown with a "shutdown /a", perform the operations you want, and then trigger another reboot.
But you should definitely try to see the problem the other way : installing when the computers are up.
Just a few more explanations to explain why we want to install softwares before the shutdown.
Many of our servers are business criticals and they have a fixe and strict time of reboot that we cannot change (we cannot also make a shutdown when we want : we have to see with the different teams and users worldwide when they will not use the servers).
That's why we would like to install the software before the "scheduled" reboot. In our case the reboot will finish the antivirus installation for example and we won't have to wait till the other "scheduled" reboot (that can be scheduled one month later for example if the server has to be rebooted just once a month)...
Hope you see better what my problem is !!!
I haven't think of the "shutdown /a" option and launch the reboot just after the package. But this will only work with the scheduled reboot and not the manual ones or the one made by other soft ...
We really want our script to be as automatic as possible, without having to check when the server will be rebooted.
Kind of script that will wait till a shutdown event, execute the package and reboot the server as it was supposed to be.