Showing posts with the label shutdown pc with python

How To Shutdown PC using Python

ShutDown PC With Python Hey my geeky friend today I'm going to tell you something special & geeky. Today you are going to learn that how can you shutdown your PC just using few lines of python code, so without wasting time let's get started. Here's the our simple python code to ShutDown PC immediately. #importing OS import os #asking from user shutdown = input("Do You Want to ShutDown You PC ? (YES / NO): ") #if user input is NO then if shutdown == 'NO': exit() #if user input is YES then else: os.system("shutdown /s /t 1") Explanation  : Here in this code we had first import os library and used os.system function with shutdown /s /t 1 code actually its a shell command. . If you hadn't imported os system in your ide import it using command prompt. One more important thing this program would directly shutdown your PC within few seconds so please make sure you have saved and closed your all important programs and applications befor