{"record":{"id":"bb3b8782fb4fc09d","repo":"GopeedLab/gopeed","slug":"batch-files-bat-cmd-are-only-supported-on-wind","errorCode":null,"errorMessage":"batch files (.bat/.cmd) are only supported on Windows","messagePattern":"batch files \\(\\.bat/\\.cmd\\) are only supported on Windows","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/download/script.go","lineNumber":84,"sourceCode":"\n\t// Determine the script interpreter based on file extension\n\tvar cmd *exec.Cmd\n\text := filepath.Ext(scriptPath)\n\t\n\tswitch ext {\n\tcase \".sh\", \".bash\":\n\t\tcmd = exec.Command(\"bash\", scriptPath)\n\tcase \".py\":\n\t\tcmd = exec.Command(\"python3\", scriptPath)\n\tcase \".js\":\n\t\tcmd = exec.Command(\"node\", scriptPath)\n\tcase \".bat\", \".cmd\":\n\t\t// Windows batch files\n\t\tif runtime.GOOS == \"windows\" {\n\t\t\tcmd = exec.Command(\"cmd\", \"/c\", scriptPath)\n\t\t} else {\n\t\t\t// Batch files are Windows-specific\n\t\t\treturn fmt.Errorf(\"batch files (.bat/.cmd) are only supported on Windows\")\n\t\t}\n\tcase \".ps1\":\n\t\t// PowerShell scripts\n\t\tif runtime.GOOS == \"windows\" {\n\t\t\tcmd = exec.Command(\"powershell\", \"-ExecutionPolicy\", \"Bypass\", \"-File\", scriptPath)\n\t\t} else {\n\t\t\t// Try pwsh (PowerShell Core) on non-Windows systems\n\t\t\tcmd = exec.Command(\"pwsh\", \"-File\", scriptPath)\n\t\t}\n\tcase \"\":\n\t\t// No extension, try to execute directly (assumes shebang or executable)\n\t\tcmd = exec.Command(scriptPath)\n\tdefault:\n\t\t// Unknown extension, try to execute directly\n\t\tcmd = exec.Command(scriptPath)\n\t}\n\n\t// Set environment variables with task information","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/GopeedLab/gopeed/blob/7b7327ffb30816273a74b142cccc0bc10c5a4c67/pkg/download/script.go#L66-L102","documentation":"Returned by executeScriptAtPath (script.go:78-85) when a configured hook has a .bat or .cmd extension but the process is not running on Windows. The interpreter switch routes .bat/.cmd to cmd /c only under runtime.GOOS == \"windows\"; on Linux/macOS (including Docker deployments of gopeed) the extension is rejected outright before any command is spawned. Like other script-hook failures it is logged as a warning, not propagated to the download.","triggerScenarios":"A Windows-authored config containing C:\\scripts\\notify.bat is reused on a Linux server or in the official gopeed Docker image; scripts developed on a Windows desktop are deployed to a NAS; a .cmd file is selected in settings while running the linux/amd64 build.","commonSituations":"Migrating gopeed settings between Windows and Linux hosts; Docker deployments inheriting a Windows config; mixed-OS teams sharing one settings file. Note .ps1 hooks do get a non-Windows fallback (pwsh), which makes .bat the surprising outlier.","solutions":["Port the hook to a cross-platform script: .sh for Linux/macOS/containers, or .ps1 which falls back to pwsh","Keep per-OS script lists and enable only the matching one on each host","If the hook must remain a batch file, run gopeed on Windows or inside a Windows container"],"exampleFix":"# before\n\"script\": { \"enable\": true, \"paths\": [\"C:\\tools\\notify.bat\"] }  # on linux -> error\n\n# after\n\"script\": { \"enable\": true, \"paths\": [\"/opt/gopeed/scripts/notify.sh\"] }  # POSIX equivalent","handlingStrategy":"validation","validationCode":"if runtime.GOOS != \"windows\" {\n\tfor _, p := range cfg.Script.Paths {\n\t\tif ext := filepath.Ext(p); ext == \".bat\" || ext == \".cmd\" {\n\t\t\treturn fmt.Errorf(\"hook %s is Windows-only on this host\", p)\n\t\t}\n\t}\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ship cross-platform hooks (.sh or .ps1) instead of .bat/.cmd","Keep per-OS script lists and enable only the matching one","When containerizing, replace Windows hooks with POSIX equivalents"],"tags":["script","windows","platform","hooks","config"],"backgroundTag":null,"analyzedSha":"7b7327ffb30816273a74b142cccc0bc10c5a4c67","analyzedAt":"2026-08-16T02:51:03.250Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}