0

I have an advanced, ever-running system of PHP CLI scripts running which do all kinds of work, and communicate with my local PostgreSQL database. Windows 10.

I never use the start menu to shut down or reboot my computer anymore. Instead, I launch a special PHP CLI script that I've made myself which allows me to safely reboot/shut down the machine by waiting until all my scripts have safely shut down, and then I shut down the PG database daemon and finally, I run the Windows "shutdown" command. I had to do this because I couldn't figure out a way for my system to "catch" the signal that Windows (supposedly) sends to all running applications before it shuts down/reboots when using the start menu (or other means).

If I ever forget about this, or want somebody else to use my system in the future, it would definitely be good if they didn't have to remember to use my special script every time they shut down or reboot them machine. It would be much better if they could use the start menu as normal, and have my system automatically "block" the shutdown/reboot until it's finished, just like other programs can (and often) do.

Is this possible from PHP CLI somehow? If so, how?

1 Answer 1

1

It is possible to define in Windows a script or program to run before shutdown is done. It does not have to be a PHP script, but it is possible as a stand-alone PHP call (using php.exe).

The shutdown script is defined in the Group Policy editor (gpedit.msc) under Computer Configuration > Windows Settings > Scripts (Startup/Shutdown). Double-click "Shutdown" and then use the Add button.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .