0
import os
print "REBOOTING"
os.system("shutdown -t 0 -r -f")

The above code is a restart script. I would like to ask whether python can support loop restart. (Automatically restart 100 times).

Thanks!

Lu儒
  • 3
  • 4
  • Does this answer your question? [restart local computer from python](https://stackoverflow.com/questions/4629131/restart-local-computer-from-python) – Kraego Aug 16 '21 at 08:15
  • Use a file to store current reboot count … – Kraego Aug 16 '21 at 08:16
  • There is iterally no reason to have a Python script that does nothing more than run a command line. Run the command line directly. Wherever you run `python reboot.py`, you could be running `shutdown -t 0 -r -f`. Use the Windows Task Scheduler, define a task with a trigger that activates every N minutes/days/hours and stops after 100 x N minutes/days/hours and you're done. No extra files, no Python, no re-inventing existing functionality. – Tomalak Aug 16 '21 at 08:25
  • I know you opinion. In this time , I want to know how to use python and let it reboot cycle and then I can try to add more function. If you have some idea , I'm glad to see. – Lu儒 Aug 16 '21 at 08:33

0 Answers0