是否可以从包中启动计划的 Windows 任务?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37532/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 11:08:04  来源:igfitidea点击:

Is it possible to start a scheduled Windows task from a package?

sql-serverwindowsssis

提问by KiwiNige

Does anyone know if you can and how to start off a scheduled Windows task on a Remote Server from within a SQL Server Integration Services (SSIS) package?

有谁知道您是否可以以及如何从 SQL Server 集成服务 (SSIS) 包中的远程服务器上启动计划的 Windows 任务?

回答by Michael Entin

Assuming you run it on Windows Server 2003/2008 or Vista, use SSIS Execute Process Task to start SCHTASKS.EXE with appropriate params (SCHTASKS /Run /?to see details).

假设您在 Windows Server 2003/2008 或 Vista 上运行它,请使用 SSIS 执行进程任务以适当的参数(SCHTASKS /Run /?以查看详细信息)启动 SCHTASKS.EXE 。

回答by Ubiguchi

It should be possible as the Task Scheduler has a scriptable COM APIthat can be used for interacting with tasks.

这应该是可能的,因为任务计划程序具有可用于与任务交互的可编写脚本的COM API

You could therefore either create a custom task that uses COM interop to call the Task Scheduler API, or it'd probably be quicker to use an Active X Script task to do your dirty work.

因此,您可以创建一个使用 COM 互操作来调用任务计划程序 API 的自定义任务,或者使用 Active X 脚本任务来完成您的脏活可能会更快。

回答by Portman

I invested a lot of time in the aforementioned COM API back in 2002. It was, to put it mildly, "flakey".

早在 2002 年,我就在前面提到的 COM API 上投入了大量时间。委婉地说,它是“古怪的”。

What we ended up doing instead is having our tasks run every minute. The first thing the task did was check the database to see if it should continue running or not.

我们最终做的是让我们的任务每分钟运行一次。任务做的第一件事是检查数据库,看它是否应该继续运行。

Then "starting" a scheduled task from SSIS was as simple as changing a database field.

然后从 SSIS“启动”计划任务就像更改数据库字段一样简单。