As we know, Python is a popular scripting language because of its versatile features. In this article, we will write a Python script to restart a computer. Let’s start with how to restart the system with Python.
Note: For this to work, you have to import
os libraryin the ide. If you don’t have it, then ‘
pip install os‘ through the Command Prompt.
Causion: Please ensure that you save and close all the program before running this code on the IDLE, as the below program will immediately restart your computer.
Below is the Python implementation –
Here is the Python Program which will ask the user to restart the computer providing the option of Yes or No. Also, when you type yes & then press the ENTER key, the system will be restart instantly.
- Python Script to Logout Computer
- Python Script to Shutdown Computer
- Python | Accepting Script Input
- Autorun a Python script on windows startup
- Python | Add Logging to a Python Script
- Python script to open a Google Map location on clipboard
- Run Python script from Node.js using child process spawn() method
- CBSE Class 12 | Computer Science - Python Syllabus
- CBSE Class 11 | Computer Science - Python Syllabus
- Computer Science Class XII (2016-17)
- Computer Vision module application for finding a target in a live camera
- Reading Python File-Like Objects from C | Python
- Important differences between Python 2.x and Python 3.x with examples
- Python | Merge Python key values to list
- Python | Sort Python Dictionaries by Key or Value
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.