It’s very easy to do it on Unix/Linux, cron is a very powerful tool for it.

But how to do it on Windows?

Run->”gpedit.msc”->”Computer Configuration\Windows Settings” for Startup/Shutdown or “User Configuration\Windows Settings” for Logon/Logoff.

Reference:
How to: Add startup and shutdown scripts in Windows – Online Training and Tutorials
Specify a Script to Run on Startup Shutdown Logon Logoff