Solved

Process doesn't run with xp_cmdshell

Posted on 2008-09-30
10
288 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

762 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

18 Experts available now in Live!

Get 1:1 Help Now