1

I am trying to run a Windows scheduler task using schtasks.exe in an SSIS job. The task will be called using the same ID as is used to execute the task. The task itself works; It is currently started manually after the SSIS job is done.

I've tried running a script on my own PC with a space in the name and this worked. All other settings are the same. The name of this task is "DWH Upload DEV" and it's location is set to "\".

I'm calling the script from an Execute Process Task block, using schtasks.exe as the executable (with the full file path of course) and /RUN /TN "DWH Upload DEV" as the arguments. I have RequireFullFileName set to False, FailTaskIfReturnCodeIsNotSuccessValue set to True and SuccessValue and TimeOut to 0

I am receiving the following error: [Execute Process Task] Error: In Executing "[location]\schtasks.exe" "/RUN /TN "DWH Upload DEV"" at "", The process exit code was "1" while the expected was "0".

The part here that confuses me is the error being at seemingly nothing.

Thanks in advance for any help!

EDIT:

I can't run the program that is performed by the scheduler from SSIS itself, due to the program needing to be run by a specific user. The use of task scheduler is a workaround for this.

Jared Posch
  • 150
  • 9
  • What does that task do? Why don't you ran that program or batch file directly? Why put it on Windows Task Scheduler instead of SQL Server Agent? – Panagiotis Kanavos May 23 '19 at 08:52
  • The program my scheduler runs needs to be started by a specific user. Since the SSIS Job will be run at night on a server PC when (presumably) no one is logged on, this scheduler task is a workaround to be able to still execute the task. Thanks for the question, I will edit it in. – Jared Posch May 23 '19 at 09:01
  • 1
    Why don't you use SQL Server Agent then? You can specify proxy accounts for various jobs, you can start job a job from T-SQL with `sp_start_job` – Panagiotis Kanavos May 23 '19 at 09:04
  • The SSIS job itself is started from an SQL Server Agent. I need quite some functionalities that SSIS offers me, both before and after running the scheduler task. – Jared Posch May 23 '19 at 09:07
  • You can still call `sp_start_job` from SSIS. Or you can split the job in multiple steps, one performing what's needed before the scheduled step, one after. – Panagiotis Kanavos May 23 '19 at 09:14
  • Thank you, I will look into it. – Jared Posch May 23 '19 at 09:20

1 Answers1

1

So, as it turned out, the task DID trigger but it didn't actually properly work (I later heard the task stopped working about an hour before I started working with it). The task can now properly be run by using the following settings:

Executable: C:\Windows\System32\schtasks.exe

Arguments: /RUN /TN "DWHUploadDEV" (the new version has no spaces in the name)

The rest of the settings is as normal.

Jared Posch
  • 150
  • 9