Is there any way to make the computer a Python program is running on restart? Generic solution is good, but in particular I’m on windows.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is no generic way of doing this, afaik.
For Windows, you need to access the Win32 API. Like so:
The win32api module is a part of pywin32.
For linux/os x, I guess calling the “reboot” command is the easiest.
Or something like that.
(Note to downvoters:
os.system()has not been deprecated. The text is “The subprocess module provides more powerful facilities for spawning new processes and retrieving their results; using that module is preferable to using this function.” For simple cases like this, when you aren’t interested in retrieving the results, nor in multiprocessing,os.system()works just fine).