April 5th, 2005, 09:28 PM
how can i write a program that will restart my computer after a certain amout of time? is there an actual command that will restart my computer programmed into python?
April 6th, 2005, 02:43 AM
what OS are you running? if you're on unix, you could just run a command through os.system("shutdown -r now"). if you're on windows, you could do something similar with os.system("C:/WINDOWS/RUNDLL32.EXE user,exitwindows") [not sure if the windows one works, never tried it]
Originally Posted by lw22
to achieve a timed shutdown on windows, you could try:
this is off the top of my head and untested, so yeah... hope it works
seconds = int(raw_input("Seconds until shutdown: "))
if (seconds >= 0): # let the user enter -1 if they want to cancel
oh and as far as I know, there is no actual 'shutdown' command 'built in' to python.
I just googled it a bit, and found that the command for shutting down windows varies from version to version. the one above is for 9x boxes and maybe 2k as well. on xp you can use "shutdown -t [number of seconds]", so you don't need to worry about using sleep. also you can use the '-r' option to restart instead of shutdown.
Last edited by rebbit; April 6th, 2005 at 06:31 AM.
Reason: found some more info