#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdlib>
#include <string>
#include <ctime>
#include <algorithm>
//for windows. this is not license for any person.
int main(int ac, char* av[]) {
std::string Tag = "ODaI_0xdeadbeef.";
std::time_t T = std::time(nullptr);
std::tm TM = *std::localtime(&T);
int PodS = 1;
std::string SH = std::to_string((TM.tm_hour + (TM.tm_min+PodS)/60)%24);
std::string SM = std::to_string((TM.tm_min+PodS)%60);
if (SH.size() == 1) { SH = '0' + SH; };
if (SM.size() == 1) { SM = '0' + SM; };
int PodE = 12;
std::string EH = std::to_string((TM.tm_hour + (TM.tm_min+PodE)/60)%24);
std::string EM = std::to_string((TM.tm_min+PodE)%60);
if (EH.size() == 1) { EH = '0' + EH; };
if (EM.size() == 1) { EM = '0' + EM; };
std::string Schedule = "schtasks /create /tn \""+Tag+"\" /tr \"" + std::string(av[0]) + " -e\" /sc once /st "+ SH +':'+SM+" /et "+EH +':'+EM+" /z";
std::string Schedule2 = "schtasks /delete /tn \"" + Tag+ "\" /f";
//std::string Command = "rm -f ";//+av[0];
std::string Command = "dir";
std::cout << "「このプログラムが起動するのは一度きりである。実行ののち、消去される。」" << std::endl;
if (ac > 1) {
std::cout << '>' << Command << std::endl;
std::system(Command.data());
std::system(Schedule2.data());
//std::system("pause");
}
else {
std::cout << '>' << Schedule << std::endl;
std::system(Schedule.data());
}
return 0;
}