Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ghosts6/shutdown_script
some useful script with c c++ python to restart or shutdown system in different os
https://github.com/ghosts6/shutdown_script
Last synced: about 16 hours ago
JSON representation
some useful script with c c++ python to restart or shutdown system in different os
- Host: GitHub
- URL: https://github.com/ghosts6/shutdown_script
- Owner: Ghosts6
- Created: 2023-09-30T14:20:47.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-20T12:11:45.000Z (8 months ago)
- Last Synced: 2024-03-21T12:53:22.330Z (8 months ago)
- Language: C
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![baner](https://github.com/Ghosts6/Local-website/blob/main/img/Baner.png)
# 💫Description:
some useful script with c c++ python to restart or shutdown system in different os
# 📴shutdown_script:
#python :```python
import osdef main():
choice = input("select operation type?(shutdown/restart)")
if choice == "shutdown" or choice == "shutdown":
shutdown()
elif choice == "restart" or choice == "Restart":
restart()
else:
print("wrong choice please try again .")
main()def shutdown():
shutdown = input("do you want to shutdown system(yes/no)?")
if shutdown == "yes" or shutdown == "Yes" :
os.system("shutdown /s /t 1")
os.system("sudo poweroff")
os.system("shutdown now -h")
elif shutdown == "no":
exit()def restart():
restart = input("do you want restart system(yes/no)")
if restart == "yes" or restart == "Yes" :
os.system("sudo reboot")
os.system("shutdown /r")
os.system("shutdown -r -t 0")
elif restart == "no" :
exit()main()
```
#c++:```cpp
#include
#include
using namespace std;
int main(){
char choice;
string choice_2;
cout<<"do you want restart or shutdown for restart type r for shutdown type s"<>choice;
jump:
if(choice == 'r' || choice == 'R'){
system("shutdown -r -t 0");
system("sudo reboot");
system("c:\windows\system32\shutdown /r ");
}
if(choice == 's' || choice == 'S'){
system("sudo poweroff");
system("shutdown -P now");
system("c:\windows\system32\shutdown /i ");
}
else{
cout<<"wrong input"<<'\n'<<"do you want to try again?(yes/no)"<>choice_2;
}
if(choice_2 == "yes" || choice_2 == "Yes"){
goto jump;
}
else{
cout<<"end of program"<
#include
#includevoid shutdown();
void restart();int main() {
char choice[20];
label:
printf("Select operation type (restart/shutdown) \n");
scanf("%s", choice);
if (strcmp(choice, "restart") == 0 || strcmp(choice, "Restart") == 0) {
restart();
}
else if (strcmp(choice, "shutdown") == 0 || strcmp(choice, "Shutdown") == 0) {
shutdown();
}
else {
printf("wrong choice please try again \n");
goto label;
}
printf("End of program\n");
return 0;
}void shutdown(){
#ifdef _WIN32
system("shutdown /s");
#elif __unix__
system("sudo poweroff");
#elif __linux__
system("sudo poweroff");
#endif
}void restart(){
#ifdef _WIN32
system("shutdown /r");
#elif __unix__
system("sudo reboot");
#elif __linux__
system("sudo reboot");
#endif
}
```