If a user is a member of Sysadmin server role of SQL Server 2005, the user runs xp_cmd_shell in the security context of SQL Server service running account. If he is not a member of sysadmin role, the server proxy account must be setup, which is saved in the SQL Server system credential ##xp_cmdshell_proxy_account##. In this case the user runs xp_cmd_shell in the proxy account. However,sometimes you set up the server proxy account, and even if the domain/windows account is added to the local
administrator group, the system stored procedure xp_cmd_shell may still fail with the error:
An error occurred during the execution of xp_cmdshell. A call to ‘LogonUserW’ failed with error code: ‘1385’
Run "net helpmsg 1385" in a windows console command, the message for the error code is:
Logon failure: the user has not been granted the requested logon type at this computer.
Actually the requetsed logon type is "log on as a batch job". The proxy account must have this privilege on the sql server local computer.
To solve the issue, run "All Programs–>Administrative Tools–>Local Security Policy", navigate to "Local Policies–>User Rights Assignment", find out "log on as a batch job" policy and double click it. If the proxy account is not in the list, add it. it’s not required to resart SQL server or agent service. It takes effect immediatley.