Solved

Process doesn't run with xp_cmdshell

Posted on 2008-09-30
10
292 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

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

Suggested Solutions

Title # Comments Views Activity
SQL Server Generate Scripts Fails 5 36
SQL Insert parts by customer 12 34
Passing Parameter to Stored Procedure 4 24
Loops and updating in SQL Query 9 31
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

803 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