chenhg5/cc-connect · error

powershell.exe not found: Windows Task Scheduler management

Error message

powershell.exe not found: Windows Task Scheduler management requires PowerShell

What it means

On Windows, cc-connect manages the daemon through Windows Task Scheduler driven by PowerShell (schtasksManager). newPlatformManager probes for powershell.exe via exec.LookPath and returns this error if it is absent, because every Task Scheduler operation in the manager shells out to PowerShell. No Manager is returned, so all daemon subcommands fail.

Source

Thrown at daemon/windows.go:35

	windowsTaskName   = ServiceName
	windowsScriptName = "cc-connect-daemon.ps1"
)

var runPowerShell = func(script string) (string, error) {
	cmd := exec.Command("powershell.exe", "-NoProfile", "-NonInteractive", "-Command", strictPowerShell(script))
	out, err := cmd.CombinedOutput()
	return strings.TrimSpace(string(out)), err
}

func strictPowerShell(script string) string {
	return "$ErrorActionPreference = 'Stop'\n" + script
}

type schtasksManager struct{}

func newPlatformManager() (Manager, error) {
	if _, err := exec.LookPath("powershell.exe"); err != nil {
		return nil, fmt.Errorf("powershell.exe not found: Windows Task Scheduler management requires PowerShell")
	}
	return &schtasksManager{}, nil
}

func (*schtasksManager) Platform() string { return "schtasks" }

func (m *schtasksManager) Install(cfg Config) error {
	if err := os.MkdirAll(DefaultDataDir(), 0755); err != nil {
		return fmt.Errorf("create data dir: %w", err)
	}
	if err := os.MkdirAll(filepath.Dir(cfg.LogFile), 0755); err != nil {
		return fmt.Errorf("create log dir: %w", err)
	}

	scriptPath := windowsTaskScriptPath()
	// 0644 has weak semantics on Windows; the file ACL is what matters.
	// We still write 0600 so the file's POSIX bits do not advertise read
	// access, and rely on the user's own profile ACLs for primary defense

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Restore powershell.exe to PATH: ensure `C:\Windows\System32\WindowsPowerShell\v1.0\` is in the PATH of the account running cc-connect
  2. Verify with `where.exe powershell.exe` in the same shell/session that runs cc-connect
  3. Reinstall/enable Windows PowerShell via 'Turn Windows features on or off' or `Add-WindowsCapability -Online -Name Microsoft.Windows.PowerShell*`
  4. If PowerShell is deliberately absent, manage cc-connect with nssm or a Windows service wrapper instead of `cc-connect daemon`

Example fix

// before (PowerShell missing from PATH)
$ cc-connect daemon install
// error: powershell.exe not found
// after (PowerShell)
$ setx PATH "$env:PATH;C:\Windows\System32\WindowsPowerShell\v1.0\"
# reopen the shell, then
$ cc-connect daemon install
Defensive patterns

Strategy: validation

Validate before calling

if _, err := exec.LookPath("powershell.exe"); err != nil {
    log.Fatal("powershell.exe not on PATH; add C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\ to PATH before running daemon install")
}
cc-connect daemon install

Try / catch

if err := daemon.Install(cfg); err != nil && strings.Contains(err.Error(), "powershell.exe not found") {
    return fmt.Errorf("install PowerShell or manage cc-connect with nssm instead: %w", err)
}

Prevention

When it happens

Trigger: `cc-connect daemon install` on Windows when powershell.exe is not on PATH — e.g. PATH missing System32\WindowsPowerShell\v1.0\, PowerShell removed by hardening policies, or running under an environment with a stripped PATH (some services/ssh sessions).

Common situations: Minimal Windows Server installs with PowerShell features removed; custom PATH configured without system paths; running cc-connect from a service account whose PATH differs from the interactive user's; Windows Nano Server without full PowerShell.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/e5493c1f4f39ebbb. Report an issue: GitHub.