#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
char cmd[20] = "shutdown -s -t ";
char times[10] = "0";
int min = 0;
int choose;
system("title Timing Shutdown Program"); //設置cmd窗口標題
system("mode con cols=50 lines=35"); //窗口寬度高度
system("color f0"); //可以寫成 red 調出顏色組
system("date /T");
system("TIME /T");
printf("\nWhat do you want me to do ...\n");
printf("\n1.Timing Shutdown\t");
printf("2.Shutdown\n");
printf("3.Logout\t");
printf("\t4.Shutdown Cancel\n");
printf("0.Exit\n\n");
printf("-> ");
while (~scanf("%d", &choose))
{
switch (choose) {
case 1:
printf("Set a timer to count down...(minutes) \n");//輸入分鐘
printf("-> ");
scanf("%d", &min);
min = min * 60;
sprintf(times, "%d", min);
system(strcat(cmd, times));
printf("Hey,you can input 4 to cancel shutdown progress whenever you want...\n");
break;
case 2:
system("shutdown -p");
break;
case 3:
system("shutdown -l");
break;
case 4:
system("shutdown -a");
break;
case 0:
exit(0);
break;
default:
printf("-> Please input right number!\n");
}
}
return 0;
}
定時關機小應用
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.