netchx/netch · error · MessageException
Copy netfilter2.sys failed {e.Message}
Error message
Copy netfilter2.sys failed
{e.Message} What it means
Thrown by NFController.InstallDriver when File.Copy(Constants.NFDriver -> %SystemRoot%\System32\drivers\netfilter2.sys) raised an exception. The native file exists (error 12 already passed) but the copy itself failed; e.Message from the IOException/UnauthorizedAccess is appended.
Source
Thrown at Netch/Controllers/NFController.cs:211
/// 安装 NF 驱动
/// </summary>
/// <returns>驱动是否安装成功</returns>
private static void InstallDriver()
{
Log.Information("Install netfilter2 driver");
Global.MainForm.StatusText(i18N.Translate("Installing netfilter2 driver"));
if (!File.Exists(Constants.NFDriver))
throw new MessageException(i18N.Translate("builtin driver files missing, can't install NF driver"));
try
{
File.Copy(Constants.NFDriver, SystemDriver);
}
catch (Exception e)
{
Log.Error(e, "Copy netfilter2.sys failed\n");
throw new MessageException($"Copy netfilter2.sys failed\n{e.Message}");
}
// 注册驱动文件
if (Interops.Redirector.aio_register("netfilter2"))
{
Log.Information("Install netfilter2 driver finished");
}
else
{
Log.Error("Register netfilter2 failed");
}
}
/// <summary>
/// 卸载 NF 驱动
/// </summary>
/// <returns>是否成功卸载</returns>
public static bool UninstallDriver()View on GitHub (pinned to 9d99eb1c5a)
Solutions
- Relaunch Netch as administrator.
- Stop the netfilter2 service first: `sc stop netfilter2` (NFController.UninstallDriver does this — call it or reboot).
- Temporarily disable antivirus/Controlled Folder Access for the Netch directory, then retry.
- Free disk space on the system drive.
- If the file is stubbornly locked, reboot and retry the install before starting any service that loads it.
Defensive patterns
Strategy: try-catch
Validate before calling
// Require elevation and a stopped driver service before attempting the copy.
if (!HasAdminRights())
throw new MessageException("Installing the NF driver requires administrator privileges.");
try { new ServiceController("netfilter2").Stop(); } catch { /* not installed */ } Try / catch
try { NFController.InstallDriver(); /* internally: File.Copy */ }
catch (MessageException ex) when (ex.Message.StartsWith("Copy netfilter2.sys failed"))
{
// ex.Message carries the inner IOException/UnauthorizedAccess detail.
SuggestRunAsAdminOrStopService(ex.Message);
} Prevention
- Always run Netch elevated when a driver install is pending.
- Stop the netfilter2 service before reinstalling so the file isn't locked.
- Add an antivirus/tamper-protection exclusion for System32\drivers\netfilter2.sys.
- Reboot to release locks if the file refuses to copy.
When it happens
Trigger: Netch is not running elevated so it cannot write to System32\drivers; an existing netfilter2.sys is locked because the driver service is still running; antivirus blocks writing a .sys into drivers; disk full; the target path is protected by tamper protection.
Common situations: User launched Netch without admin rights; previous driver still loaded and locking the file; EDR/AV preventing driver drops; Controlled Folder Access blocking the write.
Related errors
- builtin driver files missing, can't install NF driver
- Failed to copy wintun.dll to system directory: {e.Message}
- Redirector start failed.
- bin\{mainFile} file not found!
- {e.Message} Missing File or runtime components
AI-assisted analysis of netchx/netch@9d99eb1c5a (2026-08-13).
Data as JSON: /api/errors/07f3d3d768552aee.
Report an issue: GitHub.