?
Solved

Prolems when calling an .exe file from SQL server job...

Posted on 2003-03-20
15
Medium Priority
?
997 Views
Last Modified: 2008-02-01
I have created a job that has one step that calls small program with "CmdExec" command (Operating System Command). This job is currently installed on 20 different computers. The job doesn't run correctly on one of these computers.

It seems that the SQL server has some problems when using CmdExec command.
When I run the job on that computer I'll receive an following error message:
"Application error !  The application failed to initialize properly (0xc0000142), Click on Ok to terminate the application".

When I run my program from command prompt I works OK. The programs doesn't have
interface and normally it takes som 5-10 minutes to terminate the execution.

Computer configuration: Windows 2000 Pro SP2 + SQL2000

What could be a problem ? Everything was running smoothly until last week when this problem first came up.
0
Comment
Question by:vpalmu
15 Comments
 
LVL 13

Expert Comment

by:ispaleny
ID: 8177568
Several questions, all about the problematic server.
-----------------------------------------------------------
1. Can you run it from command line (CMD.EXE) ?
2. Can you run it from SQL server ?
 exec master.dbo.xp_cmdshell 'commandline'
3. Startup account of SQL Server ?
4. Startup account of SQL Server Agent ?
0
 

Expert Comment

by:amaronjob
ID: 8179385
Try by changing the path:

"C:\Documents and Settings\Administrator\Desktop\New Folder\file.exe"
or
"C:\DOCUME~1\ADMINI~1\DESKTOP\NEWFOL~1\FILE.EXE"

0
 
LVL 13

Expert Comment

by:ispaleny
ID: 8179612
vpalmu,

It can be a problem of file permissions, COM permissions,  filesystem SQL Server Agent or any other.

But you must reply first !!!!

You can try installing of W2K SP3 and SQL2K SP3.
This can prevent most issues.

(Windows 2000 Pro -> MSDE)?

0
Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

 

Author Comment

by:vpalmu
ID: 8180342
amanronjob,

I'm not using long directosy names. The directory is currently "c:\sstp". I have already tried to use the root directory "c:\" and the problem continues.
0
 

Author Comment

by:vpalmu
ID: 8180376
ispaleny,

I have thought about that, the file and directory permissions are already chekced.
SQL-Server agent + MSSQLServer are running under "sysadm" accont. I have already created another job that call my app, but that didn't help.
0
 

Author Comment

by:vpalmu
ID: 8180423
ispaleny,
Some answers:

1. Can you run it from command line (CMD.EXE) ?

- It runs ok. from command line, that's why I'm thinking  that SQL-Server might have some problems.

2. Can you run it from SQL server ?
exec master.dbo.xp_cmdshell 'commandline'

- I will try this.

3. Startup account of SQL Server ?
- Local system account (sorry about the previous "sysadm"  answer, my mistake).

4. Startup account of SQL Server Agent

- Local system account.
0
 
LVL 13

Expert Comment

by:ispaleny
ID: 8180996
Setup SQL Server Agent to login as administrator, restart SQL Server Agent and try again.
0
 

Author Comment

by:vpalmu
ID: 8183424
ispaleny,

My app runs normally with command:
"exec master.dbo.xp_cmdshell 'commandline'"

does this mean something ?? Is this different from
starting my prog form job ??

0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 8183542
>>Is this different from starting my prog form job ??<<
Sure, one is on a workstation the other is on the server.

Anthony
0
 

Author Comment

by:vpalmu
ID: 8183641
acperkins,

My app is installed on the same computer than the
SQL-Server. What I ment was, is there a differece when I run my app with the "exec" command from Query Analyzer or  when I call my app from SQL-Server job using the "CmdExec" command ??
0
 
LVL 13

Expert Comment

by:ispaleny
ID: 8186528
The executor of your job is SQL Server Agent startup account.
The executor of xp_cmdshell is SQL Server.

But you posted both are SYSTEM.
0
 
LVL 13

Accepted Solution

by:
ispaleny earned 1500 total points
ID: 8186563
You also posted, the job is timed. So it is nun at server side with SQLSERVERAGENT logon account.

Now

1. Please check once again the both services are running as SYSTEM
Go Start->Settings->Control panel->Administrative Tools
->Computer Management->Services and Applications->Services

Check the last column of the list (logon account)
for services MSSQLSERVER and SQLSERVERAGENT.
Both LocalSystem ? If they are not, change SQLSERVERAGENT logon account to MSSQLSERVER logon account.
 
2. If both LocalSystem, drop and recreate job. Do not use Copy&Paste !!! Then try once again.

3. If 2 didn't help, install latest service packs (both SP3) and start from 1.

4. Change your CmdExec job to SQLTask "exec master.dbo.xp_cmdshell 'commandline'" job. You already verified this functionality.

Good luck !
0
 
LVL 13

Expert Comment

by:ispaleny
ID: 8224293
Killed in action ?
0
 

Author Comment

by:vpalmu
ID: 8228038
Sorry for the late reply...the option 4 works. Now, I couldn't find out why CmdExec won´t work on that machine, but that's ok.
0
 
LVL 13

Expert Comment

by:ispaleny
ID: 8230946
vpalmu,
Some solution is better than none. Post later if you find ( or want to find ) why it didn't work.
Best regards, Ivo Spaleny.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Suggested Courses

580 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