In this post we will be creating a script in Python that will shut down your machine, the following is only applicable for Windows machines. To do this we will be using Pythons OS module which will enable us to functionality on the systems operating system.
The script will ask the user to confirm whether or not they are wanting to shut down the machine and to do this we will be taking input.
The source code for this project can be found below.
import os
while True:
In = input("Do you want to restart your machine now?(Y/N) ")
if In == "Y":
os.system("shutdown /s /t 1")
if In == "N":
print("OK!")