请各位c或c++高手给写个程序,定时关闭程序的

2025-02-26 00:04:39
推荐回答(2个)
回答1:

1.关闭某个程序:

taskkill /f /im iexplore.exe

将此命令保存在一个bat文件中,例如test.bat,进程名改为你的进程名。

2.使用at命令实现定时控制:例如晚上9点:
at 21:00 test.bat

通过以上两步就可以实现 执行在规定的时间内关闭某个程序

回答2:

很简单,调用系统提供的时间API,判定系统的时间,或者写一个定时器设定多久后关闭服务器,关闭服务器用sprintf(buffer,"taskkill -f -im %s",pthreadName);;System(ps);关闭名为pthreadName的进程