Visual Studio 控制台应用程序安装程序 - 计划 Windows 任务
有谁知道如何使用 Visual Studio 2010 创建安装项目来创建 Windows Scheduler 任务?我正在为需要每 X 分钟运行一次的控制台应用程序构建一个安装程序,如果客户不必手动安排它,那就太好了。
谢谢!
Does anyone know how to create an installation project using Visual Studio 2010 that creates a Windows Scheduler task? I'm building an installer for a Console Application that needs to run every X minutes, and it would be nice for the customer not to have to schedule it manually.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 Wix (.wixproj) 中,您可以在用 Jscript 编写的 CustomAction 中执行此操作,该操作调用 Schtasks.exe 。
我不知道VS2010是否支持WIX,我认为它是内置的。
自定义操作模块(.js 文件)应该有一个函数来运行 schtasks 命令,如下所示:
然后,从自定义操作函数本身中使用该命令,如下所示
有些人说在脚本中编写 CA 是错误的要做的事情,因为它们很难维护、很难调试,或者很难把它们做好。我认为这些都是不好的理由。 CA 在脚本中正确实现,运行良好。
in Wix (.wixproj) you can do it in a CustomAction, written in Jscript, that invokes Schtasks.exe .
I don't know about VS2010's support of WIX, I think it is built-in.
The custom action module (the .js file) should have a function to run a schtasks command, something like this:
And then, use that from within the custom action function itself, something like this
Some people say writing CA's in script is the wrong thing to do, because they are hard to maintain, hard to debug, or it's hard to do them right. I think those are bad reasons. CA's implemented correctly in script, work well.
WIX 有自己的自定义操作来创建窗口任务并调度它们。
上面的命令将创建一个名为“My Task”的任务,该任务将在每天中午 12 点执行。
SCHTASKS命令用于创建和安排 Windows 任务。
WIX has its own custom action for creating windows task and scheduling them.
Above command will create a task with name 'My Task' which will execute everyday at 12 AM.
SCHTASKS command is used to create and schedule a windows task.