简体   繁体   English

xp_cmdshell的问题

[英]Issue with xp_cmdshell

I am trying to copy a back up file from a remote system to local using 我正在尝试使用以下方法将备份文件从远程系统复制到本地

EXEC master.sys.xp_cmdshell 'XCopy src dest' EXEC master.sys.xp_cmdshell'XCopy src dest'

command. 命令。 The above mentioned command returns file not found error. 上面提到的命令返回文件未找到错误。 However the XCopy command copies file from the remote system to the local system when run in command prompt of the local system . 但是,在local system命令提示符下运行时, XCopy命令XCopy文件从remote system复制到local system Can somebody suggest a solution? 有人可以提出解决方案吗?

You are trying to access a remote server. 您正在尝试访问远程服务器。 When you attempt this from the command line you are using your permissions. 当您从命令行尝试此操作时,您正在使用权限。

However, xp_cmdshell is run with the permissions of the SQL Server service account. 但是,xp_cmdshell是使用SQL Server服务帐户的权限运行的。 Of course this account should be run with minimum permissions, you may need to increase its permissions to the other server. 当然,该帐户应以最小权限运行,您可能需要增加其对另一台服务器的权限。

MSDN MSDN

Also, don't forget that when the xp_cmdshell executes under the SQL account permissions that mapped network drive letters won't be available. 另外,请不要忘记,当在SQL帐户权限下执行xp_cmdshell时,映射的网络驱动器号将不可用。 You must use UNC path. 您必须使用UNC路径。 ie \\\\servername\\sharename\\path\\file 即\\\\服务器名\\共享名\\路径\\文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM