Author |
Topic |
Curt Blood
Starting Member
23 Posts |
Posted - 2008-11-21 : 12:36:38
|
Issue -- I can run the following line under SSMS in a query windowExec master..xp_cmdshell 'c:\foo.bat'I want to run this from a Job in SQL Server Agent. So I set up the job, and set up the step within the job as type "Operating System (CmdExec)" with "Exec master..xp_cmdshell 'c:\foo.bat'" for the command text.When I try to execute the line in a job, I get the following error:"The process could not be created for step 1 of job 0x9310D66B21DB8344A37C192E57789738 (reason: The system cannot find the file specified). The step failed."The SQL Server Agent is running under the same account that SQL Server is.Not sure what the deal is.Thanks in advance,Curt |
|
koolkeith19
Starting Member
14 Posts |
Posted - 2008-11-21 : 13:00:17
|
Check the permissions of the account running the SQL agent job... it is a windows account or only a sql account? |
|
|
Curt Blood
Starting Member
23 Posts |
Posted - 2008-11-21 : 13:03:57
|
It's a Windows account with Administrator rights |
|
|
tfountain
Constraint Violating Yak Guru
491 Posts |
Posted - 2008-11-21 : 13:08:14
|
If this was a permission issue, the error would read "Access is denied". Note that the reference to the location is from the perspective of server, not your machine. Is there a foo.bat file on the C drive of the SQL box? |
|
|
Curt Blood
Starting Member
23 Posts |
Posted - 2008-11-21 : 13:12:36
|
True about the permissions...Yes, everything's local -- the c:\foo.bat is in the root of the box that SQL is running on. |
|
|
tfountain
Constraint Violating Yak Guru
491 Posts |
Posted - 2008-11-21 : 14:33:50
|
What do you see when you execute this?exec master..xp_cmdshell 'dir /b /on c:\*.*' |
|
|
Curt Blood
Starting Member
23 Posts |
Posted - 2008-11-21 : 14:38:58
|
When I run it from a query window, I get a listing of the contents of my root directory (obviously)When I run it from within a job, I get:The process could not be created for step 1 of job 0x9310D66B21DB8344A37C192E57789738 (reason: The system cannot find the file specified). The step failed. |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2008-11-21 : 15:13:37
|
Just to double check, you are setting the step as a Transact SQL Type not an Operating System (CmdExec) type correct?EDIT: Ahh crap, just saw that you mentioned that in your initial post.. The Type is set wrong.. Change it to Transact SQL.EDIT2: Or keep the type and just execute C:\Foo.bat |
|
|
Curt Blood
Starting Member
23 Posts |
Posted - 2008-11-21 : 15:38:53
|
Outstanding!Ran just fine as transact-SQLThank you for de-knotting my scrambled mind.--Curt |
|
|
|