Sunday, February 19, 2012

Can't launch executable from SQL Server Agent Job

I'm trying to launch an .exe from SQL Server Agent Job and basically nothing happens. I created a job, with 1 step, type is Operating System (CmdExec), run as sql agent service account, and in the command box I typed "start notepad" (no quotes). The job owner is set to administrator. I manually start the job, it processes successfully yet notepad does not launch. I've tried with other .exe's and result is the same. Any advice? Thanks!

maybe what you need to type is notepad.exe alone

anyway you can also

place a jobstep containing

exec xp_cmdshell 'notepad.exe'

for more details on xp_cmdshell please consult BOL

or see this link

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_xp_aa-sz_4jxo.asp

thanks

joey

|||

Thanks joeydj but I've tried xp_cmdshell method and that does not work either. I've also tried launching a batch file (.bat) that calls the .exe and that does not work. The batch call (job) is successfull but again the .exe does not launch. I would like to know if anyone else has had this work for them (launch an .exe directly from a job). I'm starting to think there may be a security setting not allowing executables to be launched. My last option would be an SSIS(DTS) package but since just typing "start xxx.exe" is so straight forward I was trying to avoid the SSIS(DTS).

Note: Gosh I forgot to mention I'm using SQL Server 2005 Standard version.

|||

xp_cmdshell is disabled by default in sql server 2005.

Permissions

Execute permissions for xp_cmdshell default to members of the sysadmin fixed server role, but can be granted to other users.

|||thanks joeydj, but I don't think the permissions for xp_cmdshell is an issue. My login has sysadmin permissions.|||

http://msdn2.microsoft.com/en-us/library/ms190693.aspx

hi

please make sure you enable this by runningsurface area configuration

start>programs>micrsoft sql server 2005>configuration tools>

surface area configuration>surface area configuration for FEATURES>

>xp_cmdshell> check this option

regards,

joey

|||Thanks joeydj but xp_cmdshell is/was enabled and a proxy account with sysadmin permissions is setup for it as well. Can you answer the question: Should I be able to launch an .exe directly from SQL Server Agent Job?|||

hi odalys,

Yes. You can. you scenario and encountered the same error

anyway

here's the work around create an operating system(cmdexec) step

directly invoke command.com and pass the command as parameter

so the script should look like this

Command.com /c dir/w>mydoc.txt

regards,

joey

|||I tried the command.com /c notepad and the job just hangs, it never finishes executing.|||

same here.

|||

why do you want to do this? anyway..

is this a maintenance task or something

|||It's part of an I/O process. I create a data file from a db and have to launch the .exe to import the data. I've decided to do it through an SSIS package...But thanks for your suggestions!|||aaarrrrggghh! The package executes from SSIS but when I schedule it as a job it just hangs...it just says executing and it should not take more than a few seconds to run...|||

why not use the windows scheduler instead of a sql job?

To open Scheduled Tasks, click Start, point to Programs, point to Accessories, point to System Tools, and then click Scheduled Tasks.

|||Actually, that's how I have it running now, using Scheduled Tasks :)

No comments:

Post a Comment