Skip to content

feat(install): add Windows PowerShell installer - #579

Merged
SaladDay merged 10 commits into
mainfrom
codex/windows-install-ps1
Nov 24, 2026
Merged

SaladDay merged 10 commits into
mainfrom
codex/windows-install-ps1

Conversation

@SaladDay

@SaladDay SaladDay commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Problem

install.sh exits on Windows, and the README tells Windows users to move cc-switch.exe into C:\Windows\System32, which needs administrator rights (#525).

Behavior

irm https://raw.githubusercontent.com/SaladDay/cc-switch-cli/main/install.ps1 | iex
  • Downloads cc-switch-cli-windows-x64.zip from releases/latest/download (no GitHub API), or the tag in CC_SWITCH_VERSION (5.11.3 and v5.11.3 both work).
  • Installs cc-switch.exe to %LOCALAPPDATA%\cc-switch, or CC_SWITCH_INSTALL_DIR.
  • Overwrite rules match install.sh: prompt when interactive, refuse in non-interactive shells unless CC_SWITCH_FORCE=1.
  • Adds the directory to the user PATH only, once. Existing %VAR% entries stay unexpanded and the value keeps its registry kind (REG_EXPAND_SZ when new). Updates the current session PATH, notifies new terminals (a failed notification only warns), then runs cc-switch --version.
  • Replacing moves the old exe aside first and restores it if the new one cannot be moved in. A locked exe, or a failed download, stops with the underlying error and leaves the existing exe in place. A running cc-switch.exe is replaced; its backup is removed by the next install.
  • Stops early in Constrained Language mode (pointing to the manual steps) and for an install dir containing ;.
  • Works in Windows PowerShell 5.1 (enables TLS 1.2) and PowerShell 7. Runs inside one function, so iex leaves no variables or preference changes in the caller's session.

The script is served from main, so the one-liner works as soon as this merges and no release asset is needed. The three READMEs show the one-liner, drop the System32 step, and tell users to delete an old System32 copy.

Not included: Windows daemon / start, source builds, checksum verification (install.sh has none either).

Verification

New Install script workflow (runs only when install.ps1, a README or the workflow changes) runs the checked-out script against the real releases on windows-2022, in both powershell and pwsh: run https://github.com/SaladDay/cc-switch-cli/actions/runs/45402541957

It covers a fresh install via iex, PATH dedup and an unexpanded %USERPROFILE% entry, refusal without CC_SWITCH_FORCE, a forced overwrite of a stale exe, a locked exe (original kept, no leftovers or temp dirs), a running v5.11.3 cc-switch proxy serve replaced by the latest release, an install dir with ;, a missing release, a custom dir with a pinned version, a REG_SZ user PATH, a missing user PATH value, a failed PATH broadcast, a drive-root install dir, and the README one-liner itself (pointed at the PR commit instead of main).

Closes #525

@SaladDay
SaladDay marked this pull request as ready for review November 24, 2026 12:56
- point the README one-liner at main so it works once merged, and drop the
  unused release upload
- keep the existing user PATH value kind
- warn instead of failing when the PATH broadcast fails
- remove the staged .new file on any copy or move failure
- keep the trailing backslash of a drive-root install dir
- tell users to delete an old System32 copy
- add timeout and concurrency to the smoke workflow
- move the old exe aside before moving the new one in, restore it if that
  fails, and only say nothing was overwritten when that is true
- stop early in Constrained Language mode and on install dirs with ';'
- open the Environment key with CreateSubKey
- show PowerShell syntax for the installer env vars in the READMEs
- assert the real failed-replace path, leftovers and temp cleanup in CI
@SaladDay
SaladDay merged commit 766322a into main Nov 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows 一键安装脚本(对标 macOS/Linux install.sh)

1 participant