Access is denied when use command master..xp_cmdshell when move file from web server

  • I tried to move file on web server with command:

    exec master..xp_cmdshell 'move \\WebServerName\EdIdata\HSEFLE\INVOIC\SUCCESS\INVOIC_000003.txt \\WebServerName\EdIdata\HSEFLE\INVOIC\SUCCESS\Archive\INVOIC_000003.txt'

    out put show:

    Access is denied.

            0 file(s) moved.

    But when I use command :

    exec master..xp_cmdshell 'dir /B \\WebServerName\EdIdata\HSEFLE\INVOIC\SUCCESS\INVOIC*.txt'

    out put show:

    All files in folder \Edidata\HSEFLE\INVOIC\SUCCESS\INVOIC*.txt

     

    Both command execute on database server.

    What should I do?

    Why I can' t move web server ' s files.

  • Do you have write permission to the files?

    -SQLBill

  • No,it is normal text files.

  • Hello,

    The default share permission is READ for everyone, so your DIR command will execute, but you need CHANGE share permission and WRITE NTFS permission on the share \\WebServerName\EdIdata for the account that is used to perform the move job. In many cases it would be SQL Server Startup account and in some cases proxy account and if executed interactively (by OSQL for example) it may be your Windows account.

    Regards,Yelena Varsha

  • my permissions allow everyone to ----> "Full Control","Change","Read"

    Could you please tell me about setting share permission or setting SQL Server Startup? <step by step>

     

  • Hi,

    Right-click on the shared folder on the server and go to 1.Security Tab - Click Add and follow the screens. 2. Sharing Tab - make sure Shared As is clicked and click Permissions button.  The same could be done from the Computer Management ->System tools ->Shares right-click, New. BOTH NTFS and Share permissions should be no less then write or change (for the share) for the account that does not have access. How to find this account? In the Event Viewer on the machine where the share is go to Security log and see who is having login failures. To set SQL Server startup account go to SQL Server Properties ->Security Tab and change it providing a password. If it is SQL Server who is executing your job than the startup account should be domain account and have all these permisssions on the share that we talked about.

    Regards,Yelena Varsha

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

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