1.python

def shutdown():
	print('(1)定时关机\n(2)取消定时关机\n(3)立即关机\n(4)关机重启')
	b = eval(input('请选择:\n'))
	if(b==1):
		time = eval(input('请输入定时关机的时间:\n'))
		os.system('shutdown -s -t '+str(time*60))
		print('设置成功!电脑将在%d分钟后自动关闭。'%time)
	elif(b==2):
		os.system('shutdown -a')
		print('成功取消定时关机设置!')
	elif(b==3):
		print('确定要立即关机吗?[y/n]')
		if(input()=='y'):
			os.system('shutdown -s -t 0')
	elif(b==4):
		print('确定要立即关机重启吗?[y/n]')
		if(input()=='y'):
			os.system("shutdown -r -t 0")
	else:
		print('输入有误!')  

if __init__ == '__main__':
	shutdown()

2.C语言

输入数据即可实现定时关机:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
	char cmd[20] = "shutdown -s -t ",*temp;
	char string[16] = {0};
	int time;
	printf("输入定时关机时间分钟数:\n");
	scanf("%d",&time);
	temp = itoa(time*60,string,10);//转换为字符串 
	system(strcat(cmd,temp));
	printf("设置成功!电脑将在%d分钟后定时关机。\n",time); 
	system("pause"); 
	return 0;
}

以下是取消自动关机的程序代码:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
	system("shutdown -a");
	printf("已取消定时关机!");
	return 0;
}