How to shutdown PC using CMD and Python?
Answers
Answer:
How to shutdown PC using CMD and Python?
Explanation:
Shutdown/s/t1
Question - Shutdown
Before we know that how to shutdown PC using python & CMD, let's first know about that what is Python and what is CMD.
Python
Python is a powerful high-level, object-oriented programming language. It was created by Guido van Rossum. It was launched on 1991. It will connect with the database system, it can also read and modify files. Python also works on different platforms like, Raspberry Pi, Linux, Mac, Windows and many more platforms.
CMD
CMD is an acronym for command. It is a short form of command prompt.
Shutdown PC - Python
Now let's first know that how to shutdown PC using Python.
This is the python program to shutdown PC for windows systems.
import os
os.system('shutdown -s')
And this is the python program to shutdown PC for linux systems.
import os
os.system('sudo shutdown now')
Shutdown PC - CMD
Now let's first know that how to shutdown PC using CMD.
Step 1: Press windows + R key on the keyboard and type cmd and run it.
Step 2: Write 'shutdown /s' command on that and run it. One pop-up option will come to shutdown PC.
And if you wanna shutdown your PC immediately then you have to type this command:
>>> shutdown /s /t 00
And if you wanna shutdown your PC by timer then you have to type this command:
>>> shutdown -s -t X X X X
To stop the timer you have have to type this command:
>>> shutdown -a
This will stops the timer. Here I've used for time that when you wanna shutdown your PC, you can use any time there instead of There only accept seconds time so always enter second time to shutdown PC for timer. Suppose that if you wanna shutdown your PC in 2 hour then you have type this command 'shutdown -s -t 7200'. This will shutdown your PC automatically in 2 hours.