xp_cmdshell vs DOS command prompt running osql

  • I have a script that used to run fine, except today, I get surprised by the following mysterious problem.  I can run or execute osql command from DOS prompt, but using xp_cmdshell, I receive error stating that this command does not exist.  The sql server service is running under an account that has sysadmin role granted.  Any help would be appreciated.

     

     

    Thanks!

  • xp_cmdshell may not be getting the same "path" as a user account.  Try giving the FULL path to the command and see if that works.


    Butch

  • Make sure that the path has not changed by your LAN guys.  This sometimes happens to us without any kind of notification from them.  Not sure why they do this without warning us first, but it does happen. 

    Also, when specifying a path, use the full UNC path.

  • I am having similar problem.

    Xp_Cmd is working on my local machine but doesn't work on servers in LAN. When I am running using dos promt, it is running. Actually I am processing pdf files and putting on web server. Is there some setting to enable for running on LAN.

     

     

  • Make sure that you're using the full UNC path -- it may not be mapped on the server.

    For example:

    //servername/path/filename.ext

  • If the user logged-in does not have permissions to execute xp_cmdshell, then kindly disregard all remaining paragraphs and grant permissions. 

    If the path consistency problems mentioned above are relevent to your issue, then kindly disregard all remaining paragraphs and normalize your pathing. 

    If you are here (and particularly if you have recently patched or upgraded your Sql Server and are using Jobs or DTS to execute xp_cmdshell), I had a similar issue arise.  I needed to change the proxy account setting for Sql Server Agent. 

    In Sql Server Agent properties dialog there is a Job System tab with a check box labeled "Only users with SysAdmin privileges can execute CmdExec and ActiveScripting job steps".  If this box is checked, uncheck it and set the Proxy Account used for non administrator users.  This is not not necessarily one of the accounts that login for Sql Server or Sql Server Agent services.

  • Thank you all for your responses.  I found out that the account running SQL Server does not have permission on SQL server folder where binn files are located.  I grant permissions to the account and everything works fine.

    Thanks all again

    mbenothmane

Viewing 7 posts - 1 through 6 (of 6 total)

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