views:

251

answers:

3

I'm hoping to make a quick script to log-out/restart windows at a set time. For example, start a script to "Restart windows in ten minutes". For this implementation I don't need it to run in the background or pop=up on its own. I just want to set the script and walk away knowing that the computer will log-out/restart at a set time.

Why would I want to do this? On a corporate network, sometimes system logs will be reviewed and if one is found to be leaving X minutes too early, then complications arise. Kinda annoying.

Did I already Google it? Yep. I found this. But it wasn't too helpful. It requires a framework I couldn't find, and likely couldn't install since we don't have admin privs on these machines.

I'd like to use Python for it, and I'd really like for it to look like the user did it, not a script. Perhaps screen scraping would be the only way, and if so just point me to a quick guide or IDE and I'll post the source code for everyone.

EDIT: I also ran into this

Thanks in advance

+10  A: 

The shutdown command in batch will shutdown the computer

-s to turn it off, -f to force it, -t xx to have it shutdown in x seconds,

use the subprocess module in python to call it.

Since you want it to shutdown at a specific time, to automate the job completely you'd need to use something like autosys. Set the script up to call shutdown with a value for T equal to time you want to shut down - current time in seconds. Run it before you leave for the day, or have it set to run on start up and just ignore that stupid window it brings up.

kanja
perfect. Exactly what I was looking for.
Jweede
+1  A: 

PsShutdown is probably what you are looking for.

Sanjaya R
These tools look really useful.
Jweede
+1  A: 

You can use the shutdown command in a batch script.

Dan