From 6f5572c79891db87b9a7a2d04047884f4c7077a5 Mon Sep 17 00:00:00 2001 From: harshareddy794 Date: Thu, 1 Oct 2020 16:14:41 +0530 Subject: [PATCH] Added script for shutdown and restarting PC --- .../Restart and shutdown pc/readme.md | 2 ++ .../shutdown_restart.py | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 System-Automation-Scripts/Restart and shutdown pc/readme.md create mode 100644 System-Automation-Scripts/Restart and shutdown pc/shutdown_restart.py diff --git a/System-Automation-Scripts/Restart and shutdown pc/readme.md b/System-Automation-Scripts/Restart and shutdown pc/readme.md new file mode 100644 index 00000000..c5888d94 --- /dev/null +++ b/System-Automation-Scripts/Restart and shutdown pc/readme.md @@ -0,0 +1,2 @@ +Script added for restart and shutdown pc using python + diff --git a/System-Automation-Scripts/Restart and shutdown pc/shutdown_restart.py b/System-Automation-Scripts/Restart and shutdown pc/shutdown_restart.py new file mode 100644 index 00000000..2f1d2211 --- /dev/null +++ b/System-Automation-Scripts/Restart and shutdown pc/shutdown_restart.py @@ -0,0 +1,26 @@ +# Imprort OS library +import os + +# User input +option = int(input(""" +Enter input +[1] Shutdown +[2] Restart +[3] Quit +""")) + +# Function for shutting down pc +def shutdown(): + os.system('shutdown -s') + +# Function for restarting pc +def restart(): + os.system("shutdown /r /t 1") + +if(option == 1): + shutdown() +elif(option == 2): + restart() + +else: + exit() \ No newline at end of file