I tried to create a script with c++ which will active a batch code if user tries to shutdown his computer.
if(system("shutdown -s")){ runs batch code }