Hello. I have come across many scripts for rebooting remote computers using python, but what about the computer the script is running on? If possible, I would also like my script to run in the background so the little cmd box is not visible. Thanks in advance for your help.

I think you can have it pass the command to the computer via the os module. Like for Debian-based GNU/Linux distros you could write:

import os

The only problem I can think of is that this would require super-user privileges to execute the shut down.

With Windows, if you have the win32api module, you can try this:

import win32api

I haven't tried that before though, so you may want to look deeper into that. Hope I helped a bit!

Thanks for your help... it seems that command would work.. except it give me a type error.

import win32api
TypeError: InitiateSystemShutdown() takes exactly 5 arguments (0 given)

I will look for the documentation in the meantime.

This post on stackoverflow seems to have the skeleton code for going about and making it a service.

And there's something about using srvany.exe here.

I've never actually done this myself so I can't offer much more insight...

This question has already been answered. Start a new discussion instead.