Solved

cant launch executables in sql server agent

Posted on 2015-02-24
21
68 Views
Last Modified: 2015-03-04
Hi,

I'm unable to run an executable in the Sql Server Agent.
For example if I just wanted to open Notepad from the Sql server Agent, I did the following:
Create Job Step -> Change Type to Operating System (CmdExec) -> Command is C:\Windows\System32\Notepad.exe.
But the job doesn't do anything it just keeps executing with no results...
 What am I doing wrong, I tried a couple of commands. I even created an SSIS package to open it...the package opens the application correctly from SSIS, but once the package is in a job it doesn't open.
0
Comment
Question by:cErasmus
  • 10
  • 8
  • 2
  • +1
21 Comments
 
LVL 45

Expert Comment

by:Vitor Montalvão
ID: 40627907
Did you check the job log? Or the Event log?
Must be there something pointing to the problem.
0
 

Author Comment

by:cErasmus
ID: 40627997
Hi Vitor,

I'm looking at the log file viewer and I'm not seeing anything that was captured for this specific job.
0
 
LVL 45

Expert Comment

by:Vitor Montalvão
ID: 40628017
The job runs in the context of the SQL Server Agent account so be sure that it has the necessary permission on  C:\Windows\System32
0
 
LVL 45

Expert Comment

by:Vitor Montalvão
ID: 40628026
And you can check the history of a job in the Job Activity Monitor by right-clicking on the job's name and choosing View History:

JobHistory.PNG
0
 

Author Comment

by:cErasmus
ID: 40628082
Hi,

Maybe you misunderstood me...when I start the job it doesn't finish or give me an error it only keeps on trying to execute.
In the job history it says that I stopped it.
0
 
LVL 45

Expert Comment

by:Vitor Montalvão
ID: 40628090
Ok. I did a test myself and got the permission error for the SQL Server Agent account. It was immediate.
0
 

Author Comment

by:cErasmus
ID: 40628145
Did you get it to open Notepad?
0
 
LVL 45

Expert Comment

by:Vitor Montalvão
ID: 40628207
I think I could replicate your problem. It wasn't a permission issue as I thought.
You are only using Notepad for testing or it will be really your finally solution?
I'm getting the impression that it doesn't work with Windows programs that needs user interaction.
0
 
LVL 26

Expert Comment

by:Zberteoc
ID: 40628220
You have to understand that the Notepad will be opened ON THE SOL server machine and not on your local unless the SQL server is installed locally on your laptop/desktop.
0
 
LVL 26

Expert Comment

by:Zberteoc
ID: 40628232
What I mean is that when you try the SSIS it will execute on YOUR machine but as soon as you put your command or package into an SQL Job it will execute on the box where the SQL server resides.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 45

Expert Comment

by:Vitor Montalvão
ID: 40628250
I assumed that he tested this in the local server as I did and got the exactly the same issue.
0
 
LVL 45

Expert Comment

by:Vitor Montalvão
ID: 40628276
And if you don't cancel the job you can see the notepad.exe process in the Task Manager so I really think the problem is with programs that has GUI interaction.
0
 
LVL 15

Expert Comment

by:deepakChauhan
ID: 40628279
Please check the "processes" tab in windows task manager. you can see notepad. exe running there as a process.

if you kill the notepad process (end process) in task manager. your job will be stopped.

Reason:

CmdExec is not designed to start applications that have a user interface that interact with a user. If you use to start an application (for example, Notepad) that has a user interface,  your application start in background and then wait indefinitely until it ends. Because it pass the control to your application and it never regains control from your application.

The same is story is for xp_cmdshell as well.
0
 

Author Comment

by:cErasmus
ID: 40630003
Hi Zberteoc,

I am running the SQL on a localsystem.

Hi deepakChauhan,

I checked my task manager and did not find any instance of notepad when I started the job. You say that CmdExec doesn't allow for applications to open which has a user interface, how can I then open an application? I already created a SSIS package with an Execute Process Task to open notepad. It works fine in SSIS, but as soon as I try to run it through SQL Server Agent it gives me the same result of not opening notepad.

Hi Vitor Montalvão

I am only using Notepad for testing, I actually need to run an app to open a Cisco VPN AnyConnect.
0
 
LVL 45

Expert Comment

by:Vitor Montalvão
ID: 40630095
cErasmus, did you try to open the Cisco VPN AnyConnect with the SQL Server job?
0
 

Author Comment

by:cErasmus
ID: 40630140
Yes I tried that, and it doesn't open. You see my whole problem is that I need to automate the login with the Cisco VPN Autoconnect, so I created an AutoHotKey.exe to do this.
0
 
LVL 45

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 40630315
Looks like you'll need to find a workaround for that.
Can't you use the Windows Schedule Task utility?
0
 

Author Comment

by:cErasmus
ID: 40630341
That's what I'm thinking about, but I really wish I could have used the sql server agent, because I have a couple of jobs that need to run after each other, with different logins and depending on the connection the time it takes to finish a job can cause a conflict with the next VPN that must start with the windows scheduler.
0
 

Author Comment

by:cErasmus
ID: 40630404
Vitor, I'm going to keep this question open for now, but if I don't receive any solutions I'll award the points to you.

Thanks for the help.
0
 
LVL 45

Expert Comment

by:Vitor Montalvão
ID: 40630410
Ok. I'm sorry I couldn't help more. I also never used SQL Server jobs to open another application.
Good luck.
0
 

Author Closing Comment

by:cErasmus
ID: 40644132
Although my problem didn't get a solution Vitor was very helpful.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now