Hi,
how can I make program execute code when I will turn my PC off or hybernate him?
well, I don't wanna program that will turn off pc, I wanna make program do something (execute code) when I will turn it off, like:
int main()
{
blablabla...
// things below happens when I will turn off my pc...
blablabla2...
}
I don't know about programatically (other than editing the registry) but you can use gpedit
to schedule these types of things.
You can run your executable either at system shutdown or at user logoff using group policy editor. It works smoothly i use it all the time.
Type gpedit.msc at a command line prompt, and navigate either to :
computer settings-> windows settings -> scripts (startup / shutdown)
or
user settings-> windows settings -> scripts - >(logon / logoff)
There you can add a batch script or vbscript that simply executes your application.
If you application runs on the background and you want it to get notified when system is being terminated, then probably the only role of the script could be to notify your application (by p.e. writing something to a file).
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.