Solved

Process doesn't run with xp_cmdshell

Posted on 2008-09-30
10
290 Views
Last Modified: 2008-09-30
Dear Experts,

When I run an executable using with the following line, it fails, returning an error message 'Error, could not open output file intermediate\poi.9999':

exec master..xp_cmdshell 'C:\AppData\GrowLive\TomTom\makeov2.exe

When I run this on the command line in windows, it executes fine and produces the desired result.

Can anybody think of a reason it won't execute using xp_cmdshell - I even tried running it as sa and this didn't help.

Thanks

NIck
0
Comment
Question by:nkewney
  • 5
  • 5
10 Comments
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 22606858
Where is it attemptint to put poi.9999?  Is it possible that the account SQL Server is executing as does not have the privileges to that directory?


run this to find the account

exec master..xp_cmdshell 'set username'

and verify that the returned username has access to that directory.

It it's Network Service or Local System, and the folder it is attempting to write to is on a different share, then you have to enable a proxy account for xp_cmdshell.
0
 
LVL 1

Author Comment

by:nkewney
ID: 22606951
Hi,

Thanks for the reply.

It's sqlservice - which does have full access to the directory.

Nick
0
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 22607922
so from xp_cmdshell you can do a dir of that directory?

exec mster..xp_cmdshell 'dir "\\ABCD\Intermediate\poi.9999"'

Where \\ABCD is the parent path of of that folder.
0
 
LVL 1

Author Comment

by:nkewney
ID: 22608176
Hi Brandon,

The directory ' intermediate ' is created then deleted once the process has finished.

Maybe this is causing the problem?

Downloaded FileMon to see what was happening but it wasn't much use.

Nick
0
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 22608234
So intermediate is created, but not poi.9999?
0
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 
LVL 1

Author Comment

by:nkewney
ID: 22608261
Looks like poi.9999 is the first directory created after intermediate

7:55:44 PM      makeov2.exe:724      CREATE      C:\AppData\TomTom\intermediate\poi.9999      SUCCESS      Options: OverwriteIf  Access: 00120196      
0
 
LVL 1

Author Comment

by:nkewney
ID: 22608267
(this happens when it the process is started from the command prompt)
0
 
LVL 39

Accepted Solution

by:
BrandonGalderisi earned 500 total points
ID: 22608300
from the command prompt on the SQL Server, running in the same directory?  xp_cmdshell opens in %systemroot%\system32.  If you application is attempting to write to a relative path, or to a directory that doesn't exist (such as c:\documents and settings\SQLService\ApplicationData\TomTom), it may just not be handling the parent directory not existing.
0
 
LVL 1

Author Comment

by:nkewney
ID: 22608567
Brandon,

That's exactly the issue. It was trying to create directories in c:\Windows\System32

Thank you so much!

Nick
0
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 22608572
;)
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

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.
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

895 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

21 Experts available now in Live!

Get 1:1 Help Now