{"record":{"id":"69e6d610723e50fc","repo":"juicedata/juicefs","slug":"failed-to-set-runas-value-s","errorCode":null,"errorMessage":"Failed to set RunAs value: %s","messagePattern":"Failed to set RunAs value: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/winfsp/winfs.go","lineNumber":1256,"sourceCode":"\t}\n\n\tif logPath != \"\" {\n\t\terr = k.SetStringValue(\"Stderr\", logPath)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to set registry key: %s\", err)\n\t\t}\n\t} else {\n\t\terr = k.DeleteValue(\"Stderr\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to delete registry key: %s\", err)\n\t\t}\n\t}\n\n\t// RunAs NetworkService/LocalSystem\n\tif !asNetworkDrive {\n\t\terr = k.SetStringValue(\"RunAs\", \"LocalSystem\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to set RunAs value: %s\", err)\n\t\t}\n\t} else {\n\t\tk.DeleteValue(\"RunAs\")\n\t}\n\n\t//  SET \"HKLM\\\\SOFTWARE\\\\WOW6432Node\\\\WinFsp\\\\MountBroadcastDriveChange\" to 1\n\tk2, err := registry.OpenKey(registry.LOCAL_MACHINE, \"SOFTWARE\\\\WOW6432Node\\\\WinFsp\", registry.ALL_ACCESS)\n\tif err != nil {\n\t\tlogger.Warningf(\"Failed to open registry key for MountBroadcastDriveChange: %s\", err)\n\t} else {\n\t\tdefer k2.Close()\n\t\terr = k2.SetDWordValue(\"MountBroadcastDriveChange\", 1)\n\t\tif err != nil {\n\t\t\tlogger.Warningf(\"Failed to set MountBroadcastDriveChange value: %s\", err)\n\t\t}\n\t}\n\n\treturn nil","sourceCodeStart":1238,"sourceCodeEnd":1274,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/winfsp/winfs.go#L1238-L1274","documentation":"Thrown when k.SetStringValue(\"RunAs\", \"LocalSystem\") fails while configuring the WinFsp service's run-as account. For drive-letter mounts the library sets RunAs=LocalSystem so the launcher starts the service with system privileges; a failed write aborts registration because the service would run under the wrong account.","triggerScenarios":"Mounting as a network drive... precisely: asNetworkDrive == false and the RunAs registry write fails — insufficient privileges, missing service key, or registry access restrictions.","commonSituations":"Non-administrator shell registering a service; corporate policy blocking HKLM writes; WinFsp Services key deleted between the earlier writes and this one (uninstall race).","solutions":["Run the mount elevated as Administrator so the RunAs value can be written.","Verify the WinFsp\\Services\\juicefs-<alias> key exists; if the earlier steps succeeded it should — reinstall WinFsp if keys vanish.","Check security software or Group Policy intercepting HKLM writes.","Retry the mount after any WinFsp upgrade completes."],"exampleFix":"// before (non-elevated)\n> juicefs mount redis://... X:\n// after\n> Start-Process juicefs -ArgumentList 'mount','redis://...','X:' -Verb RunAs","handlingStrategy":"validation","validationCode":"// confirm HKLM write access before service registration\n_, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\\WOW6432Node\\WinFsp\\Services`, registry.SET_VALUE)\nif err != nil { return errors.New(\"run as Administrator\") }","typeGuard":null,"tryCatchPattern":"if err := mount(...); strings.Contains(err.Error(), \"Failed to set RunAs\") { /* run elevated, verify WinFsp\\Services key, retry */ }","preventionTips":["Run drive-letter service mounts from an Administrator shell","Don't uninstall WinFsp while a mount is being registered","Audit security software that blocks HKLM writes"],"tags":["windows","winfsp","registry","permissions"],"backgroundTag":"permission-denied","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}