使用计划任务而不是Windows服务自动化电子邮件的程序 [英] Program to Automate emails with scheduled task instead of windows services

查看:64
本文介绍了使用计划任务而不是Windows服务自动化电子邮件的程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Experts,



我想创建一个自动电子邮件提醒程序,我已经通过按钮点击事件完成了它。我相信我也知道如何使用Windows服务创建它。



现在,我希望这个程序每周只运行一次。在找到这个任务的绝对简单和完美的方法的过程中,我读到了

想象一下创建一个服务,它占用内存,绝对不做任何事情 for   7 天,仅运行   4 分钟。然后另一个 7 天等待。虽然它可能有效,但它肯定不是什么服务   for 





还有

使用计划任务。该计划任务可以轻松启动一个控制台应用程序,该应用程序读取数据库,发送电子邮件,然后退出  normal。使用计划任务 对...执行任务的事情没有错预定的基础。





现在我不知道如何创建计划任务。有人可以帮我提出想法吗?



它只是一个控制台应用程序吗?

如何安排?



我用google搜索,它总是被重定向到Windows服务。



如果有人可以帮我解决这个问题,我将不胜感激。< br $> b $ b

节日快乐!



谢谢

解决方案

< BLOCKQUOTE>是。它只是一个在Windows任务调度程序中运行的控制台应用程序。



我在Windows 10上。要做到这一点,只需搜索任务计划程序即可。



我忘记了如何在其他Windows版本中使用它。它应该位于工具或管理工具下的开始菜单上。



一旦你到达那里,这是非常自我解释的。只需创建一个新任务。将它指向您的应用程序exe。并设置一个时间表。


请参阅我对该问题的评论。你真的需要一些服务。其他应用程序将更容易终止,即使是偶然的,这将使它们不适合于调度目的。它甚至不必是您自己的服务。难道你不认为你最好使用旨在支持真正复杂的时间表的现有服务吗?它已与Windows捆绑并启用;你可以在不同的层面上使用它。它被称为Window Task Scheduler,请参阅 http://en.wikipedia.org/wiki/Windows_Task_Scheduler [ ^ ]。



首先,您可以使用命令行实用程序AT.EXE或CSHTASKS.EXE(替换AT.EXE)来安排事件,请参阅:

http://en.wikipedia.org/wiki/At_%28Windows%29 [ ^ ],

http://en.wikipedia.org/wiki/Schtasks [ ^ ],

http://technet.microsoft .com / zh-cn / library / bb490866.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/windows/desktop/bb736357%28v=vs.85%29 .aspx [ ^ ]。



您还可以使用Window Task Scheduler API,请参阅:

http://msdn.microsoft.com/en-我们/ library / windows / desktop / aa383614%28v = vs.85%29.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/windows/desktop/aa383608%28v= vs.85%29.aspx [ ^ ] 。



要了解如何在.NET中使用它,请参阅此CodeProject文章:用于.NET的新任务计划程序类库 [ ^ ]。



关于服务开发:最困难的问题是调试时的硬度。为了解决这个问题,我开发了一些两用应用程序开发技术:相同的应用程序可以交互式执行,也可以由服务控制器托管。这样,大多数调试都可以在交互模式下执行,这当然要容易得多。我在过去的回答中解释了这种技术:使用UI配置Windows服务 [ ^ ] 。



节日快乐!



-SA


Hello Experts,

I want to create a automatic email alerts program and I have done it with a button click event. I am sure I know how to create it using windows services also.

Now, I want this program to run only weekly once. On process of finding the absolute simple and perfect approach for this task, I have read "

Imagine creating a service that sits there taking up memory doing absolutely nothing for 7 days, only to run for 4 minutes. Then another 7 days of waiting. While it may work, its certainly not what a service is for.



And also

Use a scheduled task. That scheduled task could easily just start a console app which reads the database, sends the emails, and then quits as normal. Nothing wrong with using a scheduled task for something that... performs a task on a scheduled basis.



And now I don't have any idea of how to create a scheduled task. Could someone help me giving ideas?

Is it just a console application?
How to schedule that?

I have googled and it is redirected to windows services always.

I would appreciate if someone can help me with this notion.

Happy holiday!

Thanks

解决方案

Yes. It's just a console application that runs in windows task scheduler.

I'm on Windows 10. To get to it, just do a search for Task Scheduler.

I forget how to get to it in other Windows versions. It should be on the start menu under tools or administrative tools.

It's pretty self explanatory once you get there. Just create a new task. Point it to your application exe. and set up a schedule.


Please see my comment to the question. You really need some service. Other applications would be much easier to terminate, even by accident, which would make them not suitable for scheduling purposes. It doesn't even have to be your own service. Don't you think you would better off using existing service which is designed to support really complex schedules? It is already bundled with Windows and enabled; you can use it on different levels. It is called Window Task Scheduler, see http://en.wikipedia.org/wiki/Windows_Task_Scheduler[^].

First, you can schedule events using command-line utilities AT.EXE or CSHTASKS.EXE (which is replacing AT.EXE), see:
http://en.wikipedia.org/wiki/At_%28Windows%29[^],
http://en.wikipedia.org/wiki/Schtasks[^],
http://technet.microsoft.com/en-us/library/bb490866.aspx[^],
http://msdn.microsoft.com/en-us/library/windows/desktop/bb736357%28v=vs.85%29.aspx[^].

And you also can use Window Task Scheduler API, please see:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa383614%28v=vs.85%29.aspx[^],
http://msdn.microsoft.com/en-us/library/windows/desktop/aa383608%28v=vs.85%29.aspx[^].

To see how can you use it with .NET, see this CodeProject article: A New Task Scheduler Class Library for .NET[^].

As to the service development: the most difficult problem is hardness in their debugging. In response to this problem, I developed some technique of dual-use application development: the same application can be executed either interactively or as hosted by a service controller. This way, most of the debugging can be performed in the interactive mode, which is, of course, is much easier. I explained this technique in my past answer: Configure Windows Service with UI[^].

Happy holidays!

—SA


这篇关于使用计划任务而不是Windows服务自动化电子邮件的程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆