3

I'm trying to automate a SSIS package using dtexec via Task Scheduler (as I do not have rights to create it via SQL Agent) and need it done locally on my machine. I referenced this post: How to launch cmd.exe to execute command using Task Scheduler ?, but I can't get the syntax right for dtexec.

My Program Script is:

"C:\Program Files\Microsoft SQL Server\120\DTS\Binn\dtexec.exe" 

with Add Argument of:

/f “C:\Users\f9a\Desktop/HRFact.dtsx”

enter image description here

But when it runs, it pops up the cmd window for a split second, then goes away. The History shows a return code of 4.

enter image description here

I can run this in cmd.exe by typing this:

dtexec/f “C:\Users\f9a\Desktop/HRFact.dtsx” 

and it works fine. I just can't seem to get the syntax for Task Scheduler. Can you help? Thanks in advance!

-Trey

Community
  • 1
  • 1
TWaller
  • 81
  • 1
  • 7

2 Answers2

1

Just change Start In textbox value to

C:\Program Files\Microsoft SQL Server\120\DTS\Binn\

And change Program/Script textbox value to

DtExec

Useful links

Community
  • 1
  • 1
Yahfoufi
  • 2,220
  • 1
  • 22
  • 41
  • That didn't do anything different. Still has cmd window pop up for a split second then close with no results. Any other ideas? Thanks. – TWaller Apr 21 '17 at 15:17
1

(This should probably be a comment, but is a bit long for that. Sorry.)

Your task seems to work correctly. That you only see the console window pop up quickly is because DTEXEC starts (it is a console application after all), but exits immediately with an error.

The return code 4, which is the exit code (or ERRORLEVEL) DTEXEC returns, when it cannot find the package file (according to this).

Since the package seems to be located in the directory of a particular user (“C:\Users\f9a\Desktop/HRFact.dtsx”), make sure that the user that runs the task has access to this directory.

(Also for sanity, consider using a backslash before the filename, albeit that shouldn't matter)

Christian.K
  • 47,778
  • 10
  • 99
  • 143
  • Thanks, @Christian.K, but I am the user f9a, and can run it locally through the DtExecGUI and it works - I just can't seem to get the syntax right for Windows Task Scheduler. – TWaller May 02 '17 at 14:13