SQL Server Agent Powershell and CMD Steps

  • Hi,

    I have SQL2008R2 installed on a Windows 7 server-like computer.

    My task is to execute one program (unfortunately with a gui...) 7 times with different parameters from a sql server agent job.

    1st try was to use a powershell step that does something

    $P1=[Diagnostics.Process]::Start($myprog,$myparam1)

    $P1.WaitForExit()

    $P2=[Diagnostics.Process]::Start($myprog,$myparam2)

    $P2.WaitForExit()

    ...

    Unfortunately with some random executions do not work (they end after 0.1 seconds whereas they should run a couple of minutes).

    The strange thing is that, when running the same script directly from a powershell session on the server under the same account as the agent job step runs everything runs fine - always.

    The same with a simple cmd job step:

    start /wait eviews.exe myprog1.prg

    start /wait eviews.exe myprog2.prg

    ...

    Executed via sql server agent the job ends immediately while executing it directly on the server within cmd.exe yield the expected results.

    Any hints why sql server agent jobs act differently from the direct execution (like possibly ressource limitations...)? Or apart from the general problems involved with program expecting user interaction: Are there other aspects to consider than the gui stopping the program flow?

    Thank you in advance!

  • maybe you could use the agent just to call xp_cmdshell with T-SQL instead of Operating system (CmdExec)?

Viewing 2 posts - 1 through 1 (of 1 total)

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