Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access denied when copying files with xp_cmd shell - Unless drive is mapped first

Status
Not open for further replies.

bmacbmac

IS-IT--Management
Jan 26, 2006
392
US
Hi,

I am trying this script:

Code:
exec master..xp_cmdshell 'copy \\server\images15\archive\bentonwa2\BENWA2000547\36652\D3665296.* \\server3\transfer3\dsi\Bentonwa\Replace\2013000113.*'

And I am getting an error: Access is denied.

If I run that copy script from command line on the same server it runs just fine.

The '\\server' is actually a NAS storage device on our network. It is logged into our domain and the domain\administrator has full rights to the share.

The SQL service and agent are both set to run under the domain administrator account.

If I try this....

Code:
exec master..xp_cmdshell 'net use t: \\server\images15 password /user:username /persistent:yes'

exec master..xp_cmdshell 'copy \\server\images15\archive\bentonwa2\BENWA2000547\36652\D3665296.* \\server3\transfer3\dsi\Bentonwa\Replace\2013000113.*'

exec master..xp_cmdshell 'net use t: /delete'

Then the copy runs just fine. My script will copy a ton of files from a bunch of different network shares. I would like to automate this so I can't really create drive letters for each copy process... Well, I guess I could figure it out but it would be a big pain.

Anyone have an idea why the copy will work fine if I map the drive first? Any ideas how I can get around this?
 
I should also add. I can copy just fine to the \\server3\transfer3 using xp_cmdshell. I am just unable to copy FROM \\server3
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top