#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char input[10];
system("shutdown -s -t 60");
flag:
printf("1分钟之后关机,请输入\"我是猪\"三个字解除\n");
scanf("%s", input);
if (strcmp(input, "我是猪") == 0)
{
system("shutdown -a");
}
else
{
goto flag;
}
return 0;
}
补充:-s 是关闭此计算机 -t 是延迟多长时间关闭 ,后面跟秒数 例如 shutdown -s -t 60 意思是说60秒后关闭此计算机,shutdown -a是解除关机命令。
转载于:https://blog.51cto.com/survive/1701801