The execution of a computer program controls every digital device you use. Programs are a set of instructions given to a system for performing specific operations. Also, programs help the hardware and software to interact with each other. And with the help of these programs, you can also control your desktop environment. If you know basic programming, then giving instructions to your desktop with the use of pre-written programs might make you seem more extraordinary in front of your friends. So today, we’re going to start with a straightforward Python Program To Shutdown Windows Desktop.
What’s The Approach?
- Firstly we are going to import the
- Now, we’ll take the input in a variable, with
yes and noas the options.
- If the user selects no as the option, we’ll execute the
- However, if the user selects yes as the option, we’ll execute the command,
os.system("shutdown /s /t 1")
Also Read: Implement Radix Sort Using Python
Python Program To Shutdown Windows Desktop
import os shutdown = input("Do you wish to shutdown your computer ? (yes / no): ") if shutdown == 'no': exit() else: os.system("shutdown /s /t 1")