fork download
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3. #include <cstdlib>
  4. #include <string>
  5. #include <ctime>
  6. #include <algorithm>
  7.  
  8. //for windows. this is not license for any person.
  9.  
  10. int main(int ac, char* av[]) {
  11. std::string Tag = "ODaI_0xdeadbeef.";
  12. std::time_t T = std::time(nullptr);
  13. std::tm TM = *std::localtime(&T);
  14.  
  15. int PodS = 1;
  16. std::string SH = std::to_string((TM.tm_hour + (TM.tm_min+PodS)/60)%24);
  17. std::string SM = std::to_string((TM.tm_min+PodS)%60);
  18. if (SH.size() == 1) { SH = '0' + SH; };
  19. if (SM.size() == 1) { SM = '0' + SM; };
  20. int PodE = 12;
  21. std::string EH = std::to_string((TM.tm_hour + (TM.tm_min+PodE)/60)%24);
  22. std::string EM = std::to_string((TM.tm_min+PodE)%60);
  23. if (EH.size() == 1) { EH = '0' + EH; };
  24. if (EM.size() == 1) { EM = '0' + EM; };
  25. std::string Schedule = "schtasks /create /tn \""+Tag+"\" /tr \"" + std::string(av[0]) + " -e\" /sc once /st "+ SH +':'+SM+" /et "+EH +':'+EM+" /z";
  26. std::string Schedule2 = "schtasks /delete /tn \"" + Tag+ "\" /f";
  27. //std::string Command = "rm -f ";//+av[0];
  28. std::string Command = "dir";
  29.  
  30.  
  31.  
  32. std::cout << "「このプログラムが起動するのは一度きりである。実行ののち、消去される。」" << std::endl;
  33. if (ac > 1) {
  34. std::cout << '>' << Command << std::endl;
  35. std::system(Command.data());
  36. std::system(Schedule2.data());
  37. //std::system("pause");
  38. }
  39. else {
  40. std::cout << '>' << Schedule << std::endl;
  41. std::system(Schedule.data());
  42.  
  43. }
  44.  
  45. return 0;
  46.  
  47. }
Success #stdin #stdout #stderr 0s 4480KB
stdin
Standard input is empty
stdout
「このプログラムが起動するのは一度きりである。実行ののち、消去される。」
>schtasks /create /tn "ODaI_0xdeadbeef." /tr "./prog -e" /sc once /st 16:05 /et 16:16 /z
stderr
sh: 1: schtasks: not found