xp_cmdshell says executing but nothing happens

  • xp_cmdshell is enabled I run the following and it says executing but nothing actually happens it just continues to say executing when via cmd prompt it works and only takes 1 minute.

    exec master.sys.xp_cmdshell '\\servername\folder\getfile.bat'

    Any suggestions?

    Kind regards...

    ¤ §unshine ¤

  • sunshine-587009 (4/28/2010)


    xp_cmdshell is enabled I run the following and it says executing but nothing actually happens it just continues to say executing when via cmd prompt it works and only takes 1 minute.

    exec master.sys.xp_cmdshell '\\servername\folder\getfile.bat'

    Any suggestions?

    Kind regards...

    Does TaskManager show an extra process for cmd that SQL is using?

    /* ----------------------------- */
    Tochter aus Elysium, Wir betreten feuertrunken, Himmlische, dein Heiligtum!

  • I was running it from the client. Running task manager shows many many processes. Is there something in specific I should be looking for?

    ¤ §unshine ¤

  • xp_cmdshell runs on the server, not on the client. Try to run whatever your running on the server, through a command prompt, then you will see what is happening.

    /* ----------------------------- */
    Tochter aus Elysium, Wir betreten feuertrunken, Himmlische, dein Heiligtum!

  • It works through a command prompt from my desktop. i'm sure it will not have a problem on the server.

    ¤ §unshine ¤

  • I've also tried running it as a job as 'sa' with the same response. it continues to execute but does nothing.

    ¤ §unshine ¤

  • sunshine-587009 (4/28/2010)


    It works through a command prompt from my desktop. i'm sure it will not have a problem on the server.

    It does not matter that you can run it from your desktop through command prompt. xp_cmdshell executes it on the server. There are any number of differences between the two

    /* ----------------------------- */
    Tochter aus Elysium, Wir betreten feuertrunken, Himmlische, dein Heiligtum!

  • sunshine-587009 (4/28/2010)


    xp_cmdshell is enabled I run the following and it says executing but nothing actually happens it just continues to say executing when via cmd prompt it works and only takes 1 minute.

    exec master.sys.xp_cmdshell '\\servername\folder\getfile.bat'

    Any suggestions?

    Kind regards...

    this is a common security issue. The problem is that when you access any resource OUTSIDE of SQL server, like network shares, local hard drives, sp_OA type functions etc, it doesn't matter what YOUR credentials are, like Domain Admin,Local Admin etc, because SQL will not carry those credentials to the "outside of SQL" security context.

    The part that is most often misunderstood is that SQL Server uses the account it starts with to try and access the resource:

    That account is often an account which has never logged into the domain, and was never assigned permissions to get to the local disk or network share.

    As a result, you usually need to create a domain account in Active Directory, specifically grant it share access and disk access if it doesn't inherit it from Domain\Users or Domain\AuthenticatedUsers and change the account SQL Server starts with to that account.

    Once that is done, and you stop and start the SQL service to make it use that account instead of old running values, your linked server would work.

    you can prove this is the issue by simply putting in your credentials, with your domain account and password, and confirm the xp_cmdshell/sp_OACreate/linked server works when SQL is run your credentials, so you'd know you need a domain account to access the resource.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thank you!

    ¤ §unshine ¤

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply