xp_cmdshell File handling

  • Hi all,

    I use xp_cmdshell to copy a file on the server to a location on another server which is shared and given full access to every one.

    The following piece of code gives me Logon failure error.

    ...

    ...

    exec ('master.dbo.xp_cmdshell "copy D:\A.doc \\AnotherServer\Projects\"')

    ...

    ...

    How can I avoid this? I gave all kinds of permissions to every one to access/manipulate the folder on the server.

    Please tell me if I can somehow correct this.

    Thanks,

    Venkat R. Prasad.

  • You can set an xp_cmdshell proxy to make the copy. By default I believe it uses the SQL Server service account. If you haven't set a proxy, and are using something like Local Service to run SQL Server, this won't work.

  • You can set an xp_cmdshell proxy to make the copy. By default I believe it uses the SQL Server service account. If you haven't set a proxy, and are using something like Local Service to run SQL Server, this won't work.

    Thanks Steve for the reply.

    But I don't get it; as I gave every permission to all the users to access/modify the folder on the server.

    How do I change the settings on how the server connects to other machines?

    Where should I look for proxy settings?

    I use SQL server 2000 SP2 and I don't have reporting services.

  • The service account is the account that runs SQL Server. You can see this in EM, in the server properties. That is the account that likely is running your xp_cmdshell. The user who connects to SQL Server is completely irrelevant. The server runs the command, not the user that logs in.

Viewing 4 posts - 1 through 3 (of 3 total)

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