真正的简单:如何让xp_cmdshell不发布“访问被拒绝”并在帮助示例中取得成功。 [英] Real simple: How to get xp_cmdshell to keep from issuing "Access is denied" and succeed as in the help example.

查看:78
本文介绍了真正的简单:如何让xp_cmdshell不发布“访问被拒绝”并在帮助示例中取得成功。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

/* example from help .. "Access is denied" along with a pesky "NULL" on another line */

DECLARE @cmd sysname, @var sysname
SET @var = 'Hello world'
SET @cmd = 'echo ' + @var + ' > C:\var_out.txt'
EXEC master..xp_cmdshell @cmd



试用表格:


Experimenting with the form:

EXEC xp_cmdshell ''@echo SELECT [blahblah] FROM [dbo].[masterblah] WHERE [blahIdx] = 1 >> J:\blahOutput.txt''



替代方案会很棒。但是......这个应该工作(去过那里,之前做过)。



谢谢


Alternatives would be great. But ... this should work (been there, done it before).

Thanks

推荐答案

问题可能只是文件的目的地:Vista和上面要求完全管理员权限来编写或修改启动驱动器根目录中的任何文件。 SQL服务器正在执行的用户将没有该权限。更改文件夹:要么是创建的文件夹,要么是所有用户的打开访问权限,要么是现有的数据目录。
The chances are that the problem is just the destination of your file: Vista and above require full admin rights to write or modify any file in the root directory of your boot drive. The user under which SQL server is executing will not have that permission. Change the folder: either to a created folder which as "open" access for all users, or an existing data directory which does.


找到解决方案。



我之前已经完成了这个。简单更改服务类型。从网络服务到本地系统。



这可以在Computer Managment控制台中完成;属性的登录为选项卡。
Found solution.

And I had done this before. Simple change of the service type. From "NETWORK SERVICES" to "LOCAL SYSTEM".

This can be done in Computer Managment console; "Log on As" tab of the Properties.


这篇关于真正的简单:如何让xp_cmdshell不发布“访问被拒绝”并在帮助示例中取得成功。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆