Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to run exe file via sql server job ?

Author  Topic 

hdv212
Posting Yak Master

140 Posts

Posted - 2010-04-22 : 11:59:45
Hi
i want to create a job which execute an external exe file, but i don't know how to accomplish this.
can anybody help me ?
thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-22 : 14:37:51
You can call an exe from xp_cmdshell in a T-SQL job step, but it's probably easier/better to call it in an Operating System (CmdExec) job step. So just select the option in the Type dropdown in the Job Step.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

hdv212
Posting Yak Master

140 Posts

Posted - 2010-04-22 : 17:20:54
Thanks tkizer
I do this and create an step which use an 'Operation System (CmdExec)' and wrote 'calc.exe' to run sample app, then right-click on the job and hit start job, it start job but calc.exe doesn't start and job has still in pregress until i stop or cancel it.
can u provide me an example or tutorial to accomplish this ?
thanks in advance
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-22 : 17:30:09
It actually did start, you just can't see it. It's running inside SQL Server's session and not your session. So the exe that you need to start can not be interactive with the user as the user will never see the program popup.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-22 : 17:30:26
You can verify that it did start by searching for the exe in Task Manager on the database server.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

hdv212
Posting Yak Master

140 Posts

Posted - 2010-04-22 : 18:12:42
Thanks tkizer
yes, i saw it in task manager.
is there any way to see it like an standard program ?
why sql server start an app without UI mode ?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-22 : 18:35:58
There is no way to do it. It's because you are starting the app inside SQL Server which is running in its own session and the session that you are logged into. That's just how it works.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

londinium
Starting Member

1 Post

Posted - 2010-12-07 : 02:26:27
I am very sorry to up this topic but I have the same problem - I need to run exe-file from sql server job
Can anyone explain me this phrase "So the exe that you need to start can not be interactive with the user as the user will never see the program popup.". Where can I read article how to create such(noninteractive) exe-file
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-12-07 : 12:07:55
Just build a command line .NET application.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -