{"record":{"id":"bbaab7b12f365aa9","repo":"netbirdio/netbird","slug":"failed-to-remove-interface-s-w-s-bbaab7","errorCode":null,"errorMessage":"failed to remove interface %s: %w - %s","messagePattern":"failed to remove interface (.+?): %w - (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/iface/iface_destroy_windows.go","lineNumber":16,"sourceCode":"//go:build windows\n\npackage iface\n\nimport (\n\t\"fmt\"\n\t\"os/exec\"\n\n\tlog \"github.com/sirupsen/logrus\"\n)\n\nfunc (w *WGIface) Destroy() error {\n\tnetshCmd := GetSystem32Command(\"netsh\")\n\tout, err := exec.Command(netshCmd, \"interface\", \"set\", \"interface\", w.Name(), \"admin=disable\").CombinedOutput()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to remove interface %s: %w - %s\", w.Name(), err, out)\n\t}\n\treturn nil\n}\n\n// GetSystem32Command checks if a command can be found in the system path and returns it. In case it can't find it\n// in the path it will return the full path of a command assuming C:\\windows\\system32 as the base path.\nfunc GetSystem32Command(command string) string {\n\t_, err := exec.LookPath(command)\n\tif err == nil {\n\t\treturn command\n\t}\n\n\tlog.Tracef(\"Command %s not found in PATH, using C:\\\\windows\\\\system32\\\\%s.exe path\", command, command)\n\n\treturn \"C:\\\\windows\\\\system32\\\\\" + command + \".exe\"\n}\n","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/iface/iface_destroy_windows.go#L1-L33","documentation":"The Windows Destroy() disables (does not delete) the adapter via `netsh interface set interface <name> admin=disable`, locating netsh through GetSystem32Command, which falls back to C:\\windows\\system32 when PATH lookup fails. The error wraps the exec failure plus raw netsh output: interface name not found, netsh unavailable, or the process not elevated.","triggerScenarios":"Destroy() when the wintun adapter name does not match (uninstalled, renamed, or created under a different name by another version), when netsh cannot execute from the fallback path, or when the process runs without elevation.","commonSituations":"Adapter removed by a driver uninstall/reinstall; interface renamed in configuration so netsh cannot find it; broken PATH or 32-on-64-bit System32 redirection; non-admin invocation.","solutions":["List adapters with `netsh interface show interface` (or ncpa.cpl) and confirm the exact name spelling","Repair the adapter by re-running netbird up","Run the agent as an elevated service (LocalSystem is the default)","Verify netsh resolves: `where netsh` and that C:\\Windows\\System32\\netsh.exe exists"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"ifaces, err := net.Interfaces()\nif err == nil {\n    for _, i := range ifaces {\n        if i.Name == name {\n            return nil // exists, safe to Destroy\n        }\n    }\n    return nil // adapter already gone\n}","typeGuard":null,"tryCatchPattern":"if err := w.Destroy(); err != nil {\n    if strings.Contains(err.Error(), \"not found\") {\n        return nil // adapter no longer present\n    }\n    return err\n}","preventionTips":["Match the adapter name exactly (case and spaces) with configuration","Repair the adapter by re-running netbird up","Run the agent as an elevated service so netsh can succeed"],"tags":["go","windows","netsh","adapter","teardown"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}