run a console application by using SQL Server Agent

  • Hi,

    I would like to run a console application (vb code written on visual studio) by creating a CmdExec in SQL Server Agent.

    According to the tutorial http://www.sqlservercentral.com/articles/Stairway+Series/72459/

    It works when I typed in "dir c:\" for the command.

    But how can I execute my console application?

    Path => C:\Code\Nota 2011\Nota-Unit-3\Nota\ConsoleOutlookIntegration

    File name => Module1.vb

    Project name => ConsoleOutlookIntegration.vbproj

    Thanks in advance,

  • Compile the console app. Then just type in your executable name and path instead of "dir c:\" for the command.

  • You do not run your VB project - you need a Deployment Project that will reference primary output of your VB project. (There are walkthroughs for that.)

    Then you buld your deployment project, which will result in a pair of msi/exe installer files. Use either of these to deploy your project to a directory accessible to SQLS, and reference the deployed executable.

    Good luck!

  • I forgot to mention that before you build your project for deployment, you ought to make sure that you build a Release version. (Not Debug.)

  • Thank you. I'll try tomorrow and let you know 🙂

  • http://msdn.microsoft.com/en-us/library/fyh6k4k4.aspx

    Is this the walk through link I have to follow?

  • Yes, that is a good start.

    If you run into a problem, I am here.

  • I got an error when I want to add job step in the SQL Server Agent.

    - I selected "Operating System (CmdExec)" type.

    - In the textbox for command, I typed in path and file name.

    "C:\Program Files (x86)\Microsoft\ConsoleOutlookIntegration_DeploymentProject\ConsoleOutlookIntegration.exe"

    When I run this job, I got an error saying as follow..

    Executed as user: XXX\User1. The process could not be created for step 1 of job 0x05711F5BB33E1F47B4724AE6B841E29E (reason: The system cannot find the file specified). The step failed.

    What can I do to solve this?

    Thanks again

  • This looks like permissions problem.

    Please make sure that the SQLS Engine has access rights to the respective directory.

    BTW, typically SQLS jobs are deployed into a separate directory, not into Program Files. You give SQLS access to that directory and whenever you create one underneath it for a particular project, it inherits the permissions.

  • I am experiencing the same issue but with EPPLUS any ideas?

    Thanks

    Message

    Executed as user: WIN2016-SFD-02\SYSTEM. Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'EPPlus, Version=4.1.0.0, Culture=neutral, PublicKeyToken=ea159fdaa78159a1' or one of its dependencies. The system cannot find the file specified. at OracletoExcel.Program.Main(String[] args). Process Exit Code -532462766. The step failed.

  • richard.tinkler (12/14/2016)


    I am experiencing the same issue but with EPPLUS any ideas?

    Thanks

    Message

    Executed as user: WIN2016-SFD-02\SYSTEM. Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'EPPlus, Version=4.1.0.0, Culture=neutral, PublicKeyToken=ea159fdaa78159a1' or one of its dependencies. The system cannot find the file specified. at OracletoExcel.Program.Main(String[] args). Process Exit Code -532462766. The step failed.

    Unfortunately this is a five year old thread so you would want to create a new post for this. It's also different errors.

    The Exit code I believe is just a generic error message for .Net code with unhandled exception.

    Could not load file or assembly or one of it's dependencies has many different reasons. You could start going through the list of possible solutions at:

    http://stackoverflow.com/questions/4469929/could-not-load-file-or-assembly-or-one-of-its-dependencies

    Sue

Viewing 11 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply