Skip to content Skip to sidebar Skip to footer

How Do I Resolve This "access Is Denied" Error Which Occurs When Using Xp_cmdshell In Microsoft Sql?

This is my entire routine: Declare @AttFileType as char(5), @HQCo as int, @FormName as Varchar(15), @KeyID as VarChar(10), @UniqueID as uniqueidentifier, @FilePath as Varcha

Solution 1:

There are a couple of possible issues here.

xp_cmdShell runs on the server. If that machine does not have a folder called C:\Users\*****\Desktop\Test_Images it will not work.

xp_CmdShell runs using the service account. If that account does not have permissions on the target folder it will fail.

xp_CmdShell has to be enabled. From MSDN.

The xp_cmdshell option is a SQL Server server configuration option that enables system administrators to control whether the xp_cmdshell extended stored procedure can be executed on a system. By default, the xp_cmdshell option is disabled on new installations and can be enabled by using the Policy-Based Management or by running the sp_configure system stored procedure.

Solution 2:

I figured it out!

Thank you @destination-data & @GarethLyons for all the help!

You guys were right, there was an issue with the folder permissions I didn't realize that I would have to go into the folder and manually update the permissions to include "Service". Once I did, everything worked perfectly!

Thank you both again, sorry for the confusion.

For anyone else who is having this issue in the future, do the following first:

1) Go to the folder

2) Right click

3) Select properties

4) Select the Security tab

5) Click Advanced

6) Click Add

7) Click select a principle

8) Enter "Service" and Check Names

9) Select Service and click OK

10) Select the appropriate permissions under "Basic Permissions"

11) Select "Only apply these permissions to the object in this container"

12) Apply the changes and try running xp_cmdshell again

Post a Comment for "How Do I Resolve This "access Is Denied" Error Which Occurs When Using Xp_cmdshell In Microsoft Sql?"