{"record":{"id":"88e48bdda1e1c076","repo":"siyuan-note/siyuan","slug":"not-found-elevator-s","errorCode":null,"errorMessage":"not found elevator [%s]","messagePattern":"not found elevator \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kernel/model/elevator_windows.go","lineNumber":65,"sourceCode":"\t}\n\n\tif !isUsingMicrosoftDefender() {\n\t\treturn\n\t}\n\n\televator := getElevatorBin()\n\tif !gulu.File.IsExist(elevator) {\n\t\tlogging.LogWarnf(\"not found elevator [%s]\", elevator)\n\t\treturn\n\t}\n\n\tinstallPath := filepath.Dir(util.WorkingDir)\n\tlogging.LogInfof(\"use elevator to add Windows Defender exclusion path [%s, %s]\", installPath, util.WorkspaceDir)\n\n\tif !gulu.File.IsExist(elevator) {\n\t\tmsg := fmt.Sprintf(\"not found elevator [%s]\", elevator)\n\t\tlogging.LogWarn(msg)\n\t\terr = errors.New(msg)\n\t\treturn\n\t}\n\n\t// 工作空间路径由用户自由指定，这里校验并转义，避免路径中的 cmd.exe 元字符导致提权后命令注入\n\tif err = validateExclusionPath(installPath); nil != err {\n\t\tlogging.LogWarnf(\"invalid Windows Defender exclusion path [%s]: %s\", installPath, err)\n\t\treturn\n\t}\n\tif err = validateExclusionPath(util.WorkspaceDir); nil != err {\n\t\tlogging.LogWarnf(\"invalid Windows Defender exclusion path [%s]: %s\", util.WorkspaceDir, err)\n\t\treturn\n\t}\n\n\tps := []string{\"add-defender-exclusion\", syscall.EscapeArg(installPath), syscall.EscapeArg(util.WorkspaceDir)}\n\tverbPtr, _ := syscall.UTF16PtrFromString(\"runas\")\n\texePtr, _ := syscall.UTF16PtrFromString(elevator)\n\tcwdPtr, _ := syscall.UTF16PtrFromString(util.WorkingDir)\n\targPtr, _ := syscall.UTF16PtrFromString(strings.Join(ps, \" \"))","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/elevator_windows.go#L47-L83","documentation":"AddMicrosoftDefenderExclusion elevates via a helper executable ('elevator') to add the install path and workspace dir to Windows Defender exclusions. Before invoking it, the function checks gulu.File.IsExist(elevator); if the bundled elevator binary is missing it logs a warning, constructs 'not found elevator [%s]', and returns that error. This is a fail-fast guard so the caller does not attempt an unauthorized command with a non-existent helper.","triggerScenarios":"Calling AddMicrosoftDefenderExclusion on Windows when the elevator executable's expected path (resolved relative to util.WorkingDir) does not exist — typically because the installation is incomplete/corrupted, the binary was removed by antivirus or cleanup tools, or the working directory is wrong (e.g. running from a dev build or portable layout lacking the elevator file).","commonSituations":"Windows setup where Defender or another AV quarantined the elevation helper; portable/dev checkout without the packaged elevator binary; broken or moved installation directory so the relative path no longer resolves; running the kernel outside the normal installed layout.","solutions":["Verify the elevator executable exists next to the SiYuan installation (reinstall/repair SiYuan to restore it).","Check antivirus quarantine logs and whitelist/restore the elevator binary, then retry.","Run SiYuan from the correct working directory (util.WorkingDir) so the relative elevator path resolves; avoid launching the binary directly from an unrelated cwd.","If you do not need Defender exclusions, skip the call — this error is non-fatal to the app itself (logged as a warning)."],"exampleFix":"// before: elevator path resolved from an unexpected cwd -> \"not found elevator [elevator.exe]\"\n// after: launch from the install directory so the helper resolves\n// cd C:\\Path\\To\\SiYuan; SiYuan.exe  (or repair the installation so the elevator binary exists)","handlingStrategy":"fallback","validationCode":"// Go: probe the elevator before requesting the exclusion\nif !gulu.File.IsExist(elevatorPath) {\n    log.Warn(\"Defender exclusion skipped: elevator binary missing\")\n    return nil // or surface a repair hint to the user\n}","typeGuard":null,"tryCatchPattern":"if err := AddMicrosoftDefenderExclusion(); err != nil {\n    logging.LogWarnf(\"Defender exclusion skipped: %v\", err) // non-fatal; app continues\n}","preventionTips":["Install SiYuan via the official installer so the elevator binary ships with the app","Whitelist the install directory in AV software to prevent quarantine of the elevation helper","Do not move or rename the installation folder after install","Treat this failure as non-fatal: log and continue rather than blocking startup"],"tags":["windows","defender","elevation","missing-binary"],"backgroundTag":"file-not-found","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}