大网数据广告活动
数据库与应用安全

Error message when you run the Distribution Agent

· 52CE 我爱测

This article provides workarounds for the problem when you run the Distribution Agent in SQL Server.

This article helps you work around the problem when you run the Distribution Agent in SQL Server.

Original product version:   SQL Server
Original KB number:   956032

Symptoms

On an instance of Microsoft SQL Server that is installed on a Windows Server -based computer, you configure a transactional publication. You use the Distribution Profile for OLEDB streaming profile for the Distribution Agent. When you run the Distribution Agent, you receive an error message like the following one:

The distribution agent failed to create temporary files in C:\Program Files\Microsoft SQL Server\<nnn>\COM directory. System returned errorcode 5.

Note: <nnn> identifies the version of SQL Server. For more information, see File Locations for Default and Named Instances of SQL Server.

Cause

When you use the Distribution Profile for OLEDB streaming profile for the Distribution Agent or you use OLEDB streaming in a custom profile, prior to SQL Server 2019, the Distribution Agent creates temporary files in the directory: C:\Program Files\Microsoft SQL Server\<nnn>\COM.

Note: In SQL Server 2019 and higher versions, these temporary files are now created under the account that is running the Distribution Agent, so instead of the directory C:\Program Files\Microsoft SQL Server\<nnn>\COM, these files would be in the directory C:\Users\DistributionAgentAccount\AppData\Temp. The DistributionAgentAccount is the account under which the Distribution Agent is running.

If the account that is running SQL Server Agent doesn't have write access to the COM folder, the Distribution Agent will fail when it's running as a job. If you run the Distribution Agent from a command line by using an account that doesn't have write access to the COM folder, the same failure will occur.

Workaround

To work around this issue, grant write permissions to the COM folder for the account that is running the SQL Server Agent service. If you run the Distribution Agent from a command line, grant write permissions to the COM folder for the account that you use to run the Distribution Agent.

Note: If you change the account that is assigned to the replication job, the account should have write permissions to the COM folder.

If you still encounter this issue intermittently after you follow these steps, you should make sure that the COM folder is excluded from any antivirus scan that occurs on the system.

More information

Error code 5 indicates that the error is "access is denied."

Source: Microsoft Learn / IT Pro troubleshooting by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / IT Pro troubleshooting
适用范围
See source applicability · Source date 02/22/2021
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。