Steefmaester

Shutdown

Oct 13th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1. // by steef
  2. #include <iostream>
  3. #include <cstdlib>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     string time;
  11.     int val;
  12.     cout << "voulez-vous effectuer un arret(1) ou annuler un arret planifie(2) ?" << endl;
  13.     cout << "Entrez un chiffre : " << endl;
  14.         cin >> val;
  15.  
  16.         if (val == 1) {
  17.             cout << "Entrez l'heure d'arret de la machine (format-> XXhXX)" << endl;
  18.            
  19.            
  20.             getline(cin, time);
  21.             getline(cin, time);
  22.  
  23.             if (time.size() != 5) cout << "erreur de saisie" << endl;
  24.             else
  25.             {
  26.  
  27.                 int heure = stoi(time.substr(0, 2));
  28.                 int minutes = stoi(time.substr(3, 4));
  29.  
  30.                 int seconde;
  31.  
  32.                 cout << "Ton ordinateur s'eteindra dans " << heure << " heure(s) et " << minutes << " minute(s)" << endl;
  33.  
  34.                 seconde = (minutes * 60) + (heure * 3600);
  35.  
  36.                 cout << "Soit dans " << seconde << " seconde(s)" << endl;
  37.                 string command = "C:/Windows/System32/shutdown.exe -s -t " + to_string(seconde);
  38.                 cout << command << endl;
  39.                 system(command.c_str());
  40.  
  41.             }
  42.         }
  43.         else if (val == 2)
  44.             system("C:/Windows/System32/shutdown.exe -a");
  45.         else cout << "erreur de saisie" << endl;
  46.  
  47.  
  48.         getline(cin, time);
  49.         getline(cin, time);
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment