I have some scripts I want run if the machine is about to shutdown. Is it possible to launch a task on shutdown that's executes a script? If so, how much time does it have?
Ed
Technology Tips and News
I have some scripts I want run if the machine is about to shutdown. Is it possible to launch a task on shutdown that's executes a script? If so, how much time does it have?
Ed
Here is a discussion on handling Windows shutdown events.
http://stackoverflow.com/questions/148733/intercept-windows-vista-shutdown-event-in-c-sharp
You can specify a script to run on shutdown.
Assign computer shutdown scripts
You need to put into consideration what the script is doing and what happens if it is unable to finsih. Something you can adjust is the time windows will wait for it to execute.
http://msdn.microsoft.com/en-us/library/ms811643.aspx
Remember that a long ruining logoff or shutdown script can be just as annoying as a long logon or start up script.
As jrv pointed out you can also utilize .Net. I wrote a service some years back that would write the GUID for symantic to a remote share and then reload it upon start up. This was for non persistent virtual server to avoid first time scan.
Mike
My point exactly. You cannot control teh shutdown except AFTER it occurs. YO ucannot cancel teh shutdown because, by the time the script is executed, the computer is nearly shutdown.
If you want to effect a user session you need to ise a logoff script. If you need to just do some simple local or broadcast items use a shutdown script.
The computer is shutting down so you cannot start any new programs.
If we really need to control the shutdown then it is necessary to create a system service of some kind that has the ability to control the shutdown.