GopeedLab/gopeed · warning
batch files (.bat/.cmd) are only supported on Windows
Error message
batch files (.bat/.cmd) are only supported on Windows
What it means
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.
Source
Thrown at pkg/download/script.go:84
// Determine the script interpreter based on file extension
var cmd *exec.Cmd
ext := filepath.Ext(scriptPath)
switch ext {
case ".sh", ".bash":
cmd = exec.Command("bash", scriptPath)
case ".py":
cmd = exec.Command("python3", scriptPath)
case ".js":
cmd = exec.Command("node", scriptPath)
case ".bat", ".cmd":
// Windows batch files
if runtime.GOOS == "windows" {
cmd = exec.Command("cmd", "/c", scriptPath)
} else {
// Batch files are Windows-specific
return fmt.Errorf("batch files (.bat/.cmd) are only supported on Windows")
}
case ".ps1":
// PowerShell scripts
if runtime.GOOS == "windows" {
cmd = exec.Command("powershell", "-ExecutionPolicy", "Bypass", "-File", scriptPath)
} else {
// Try pwsh (PowerShell Core) on non-Windows systems
cmd = exec.Command("pwsh", "-File", scriptPath)
}
case "":
// No extension, try to execute directly (assumes shebang or executable)
cmd = exec.Command(scriptPath)
default:
// Unknown extension, try to execute directly
cmd = exec.Command(scriptPath)
}
// Set environment variables with task informationView on GitHub (pinned to 7b7327ffb3)
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
Example fix
# before
"script": { "enable": true, "paths": ["C:\tools\notify.bat"] } # on linux -> error
# after
"script": { "enable": true, "paths": ["/opt/gopeed/scripts/notify.sh"] } # POSIX equivalent Defensive patterns
Strategy: validation
Validate before calling
if runtime.GOOS != "windows" {
for _, p := range cfg.Script.Paths {
if ext := filepath.Ext(p); ext == ".bat" || ext == ".cmd" {
return fmt.Errorf("hook %s is Windows-only on this host", p)
}
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of GopeedLab/gopeed@7b7327ffb3 (2026-08-16).
Data as JSON: /api/errors/bb3b8782fb4fc09d.
Report an issue: GitHub.