python

Python Script to Restart Computer

Here we are writing a python program that will restart the computer or Laptop by asking the user to enter minutes, after which the computer will restart.

.

import os

class Restart(object):
 def __init__(self, timer = 0):
  self.timer = int(timer)

 def __repr__(self):
  os.system(f"shutdown -r -t {self.timer * 60}")
  return str(f"System will restart in {self.timer} minutes!")

 if __name__ == "__main__":
  try:
   restart_in = int(input("Enter the Minutes unit to restart :"))
   Restart(restart_in)
  except:
   Restart()

More Reading

Post navigation

Leave a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *