Skip to content

natnew/Python-Project-Shutdown-and-Restart-Computer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Python Project: Shutdown and Restart Computer 🐍

Python Script
This repo contains python code that shuts down or turns off your computer depending on your input.
Type 'r' to restart or 's' to shut down.

import os
import platform

def shutdown():
    if platform.system() == "Windows":
        os.system('shutdown -s')
    elif platform.system() == "Linux" or platform.system() == "Darwin":
        os.system("shutdown -h now")
    else:
        print("Os not supported!")

def restart():
    if platform.system() == "Windows":
        os.system("shutdown -t 0 -r -f")
    elif platform.system() == "Linux" or platform.system() == "Darwin":
        os.system('reboot now')
    else:
        print("Os not supported!")


command = input("Use \'r\' for restart and \'s\' for shutdown: ").lower()

if command == "r":
    restart()
elif command == "s":
    shutdown()
else:
    print("Wrong letter")

About

Python Projects - Shutdown and Restart Computer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages