Solved

cant launch executables in sql server agent

Posted on 2015-02-24
21
74 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 47

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
 
LVL 1

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 47

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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 47

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
 
LVL 1

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 47

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
 
LVL 1

Author Comment

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

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
 
LVL 47

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 47

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
 
LVL 1

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 47

Expert Comment

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

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 47

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
 
LVL 1

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
 
LVL 1

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 47

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
 
LVL 1

Author Closing Comment

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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

773 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