Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

cant launch executables in sql server agent

Posted on 2015-02-24
21
Medium Priority
?
91 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 8
  • 2
  • +1
21 Comments
 
LVL 52

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 52

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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 52

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 52

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 52

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 27

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 27

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 52

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 52

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:Deepak Chauhan
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 52

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 52

Accepted Solution

by:
Vitor Montalvão earned 1500 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 52

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

618 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