I am getting file not found on xp_cmdshell dir on local directory

前端 未结 2 2010
既然无缘
既然无缘 2021-01-27 11:58

Here is what I am trying to execute:

exec xp_cmdshell \'dir \"D:\\Data\\GS Products\" /AD /S /B\'

This works with every other folder on data th

相关标签:
2条回答
  • 2021-01-27 12:37

    Well, didnt get much help this time, but maybe I did it wrong..anyway, I had to add the SQL Service account pemissions to the folder I was doing the command on. Even though I was logged in with the top admin login, it did not work until I added the permissions to the folder/subfolders.

    0 讨论(0)
  • 2021-01-27 12:49

    Right click folder you are importing from and click Properties, go to Security tab click Edit.

    Add "Everyone".

    Apply and OK.

    See image for all details:

    Your:

    exec xp_cmdshell 'dir "D:\Data\ImportFolder" /AD /S /B'
    

    will work now.

    Note: xp_cmdshell needs only read permissions so you don't have to put full. I needed full because script I have need to write log file on the end in same folder.

    0 讨论(0)
提交回复
热议问题