Saturday, February 25, 2012

CmdExec Job Step in Sql Server2000

Thanks for the invitation to post a question, so I will post one.

I need to create a job step that uses cmdExec.

This is the command line I entering:
D:\odbc\TimeClockUpdates\bin\Release\TimeKeepingNo nLogouts.exe

When I run this job the job fails. When I look at the job history, the only information I get is the date and time, user that ran the job and the fact that it failed. I haven't been able to get any CmdExec job to run at all. Can anyone tell me what I'm doing wrong?

Facts.
1. This exact same command is used by my network administrator using windows scheduler on the server. The only reason he wants me to create an sql server job is because it's mostly sql functions.
2. I know the Sql Server agent is running, because I have other jobs that are run.
3. I have verified that I have permission to run the file because I can go to the actual directory and run the exe.
4. Do I need to enclose my command in quotes i.e. D:\odbc\TimeClockUpdates\bin\Release\TimeKeepingN onLogouts.exe
5. the path of the file I need to run is the path on the server and not the path on my local machine.

If you need any other information, please let me know
Thanks for you help
GEMyou should post the code.

cmdexec requires that the security account executing job have sysadmin permissions.|||I wish I knew what code you mean me to post

This is a job I created using enterprise manager to create the job.
1. I entered the Job Name: UpdateEmployeeLogins
2. Job type: Operation System Command (CmdExec)
3. Command: D:\odbc\TimeClockUpdates\bin\Release\TimeKeepingNo nLogouts.exe

I did all this through Enterprise Manager. What code do you want me to post?

Thanks
GEM|||change the command type to t-sql and try this...

EXEC xp_cmdshell 'D:\odbc\TimeClockUpdates\bin\Release\TimeKeepingN o nLogouts.exe'|||I did as you suggested and but the same result. I then ran that command line with query analyzer and got an "Access Denied" Error so that means I must have a problem somewhere with permissions. This doesn't make a whole lot of sense since I can the exe when clicking on it. I will have to get with out network administrator who's not available right now.

Your help was excellent, I hope you'll be around later to help me with this if I need it.

Thanks
GEM|||see my 1st post.|||This is a job I created using enterprise manager to create the job.
1. I entered the Job Name: UpdateEmployeeLogins
2. Job type: Operation System Command (CmdExec)
3. Command: D:\odbc\TimeClockUpdates\bin\Release\TimeKeepingNo nLogouts.exe

This method should work. It should not be necessary to use xp_cmdshell in your job.
As Thrassy stated, this is likely due to a permissions issue regarding the account that the SQL Agent service is running under.|||As everyone else said, make sure that the account executing the command under the SQL service privileges has the appropriate access to the executable. I bet if you look under NTFS security on the target .exe you'll find the problem.

No comments:

Post a Comment