先用一般使用者身分開啟 PS 視窗, 用下列指令設定 PowerShell 視窗腳本執行原則 (Execution Policy), 以便能執行從網路下載具有數位簽章的 PowerShell 腳本程式 Scoop :
PS C:\Users\USER> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
然後用下列指令從網路下載 Scoop 腳本執行安裝 :
PS C:\Users\USER> Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression
Initializing...
Downloading...
Creating shim...
Adding ~\scoop\shims to your path.
Scoop was installed successfully!
Type 'scoop help' for instructions.
接下來即可利用 Scoop 來安裝 Git, 主要目的是要利用 Git 所附的 git-bash 來執行 Claude Code :
PS C:\Users\USER> scoop install git
Installing '7zip' (26.01) [64bit] from 'main' bucket
7z2601-x64.msi (1.9 MB) [=====================================================================================] 100%
Checking hash of 7z2601-x64.msi ... ok.
Extracting 7z2601-x64.msi ... done.
Linking ~\scoop\apps\7zip\current => ~\scoop\apps\7zip\26.01
Creating shim for '7z'.
Creating shim for '7zG'.
Making C:\Users\USER\scoop\shims\7zg.exe a GUI binary.
Creating shim for '7zFM'.
Making C:\Users\USER\scoop\shims\7zfm.exe a GUI binary.
Creating shortcut for 7-Zip\7-Zip File Manager (7zFM.exe)
Creating shortcut for 7-Zip\7-Zip Help (7-zip.chm)
Persisting Codecs
Persisting Formats
Running post_install script...done.
'7zip' (26.01) was installed successfully!
Notes
-----
To register the context menu entry, please execute the following command:
reg import "C:\Users\USER\scoop\apps\7zip\current\install-context.reg"
If an error occurs while attempting to delete files during uninstallation, run the following command and then retry:
Stop-Process -Name 'explorer'
Installing 'git' (2.54.0) [64bit] from 'main' bucket
PortableGit-2.54.0-64-bit.7z.exe (56.3 MB) [==================================================================] 100%
Checking hash of PortableGit-2.54.0-64-bit.7z.exe ... ok.
Extracting PortableGit-2.54.0-64-bit.7z.exe ... done.
Running pre_install script...done.
Linking ~\scoop\apps\git\current => ~\scoop\apps\git\2.54.0
Creating shim for 'sh'.
Creating shim for 'git'.
Creating shim for 'git-bash'.
Making C:\Users\USER\scoop\shims\git-bash.exe a GUI binary.
Creating shim for 'gpg'.
Creating shim for 'gpg-agent'.
Creating shim for 'gpgconf'.
Creating shim for 'gpg-connect-agent'.
Creating shim for 'pinentry'.
Making C:\Users\USER\scoop\shims\pinentry.exe a GUI binary.
Creating shortcut for Git\Git Bash (git-bash.exe)
Creating shortcut for Git\Git CMD (git-cmd.exe)
Creating shortcut for Git\Git GUI (git-gui.exe)
Adding ~\scoop\apps\git\current\cmd to your path.
Running post_install script...done.
'git' (2.54.0) was installed successfully!
Notes
-----
To register file associations, please execute the following command:
reg import "C:\Users\USER\scoop\apps\git\current\install-associations.reg"
To register the context menu entry, please execute the following command:
reg import "C:\Users\USER\scoop\apps\git\current\install-context.reg"
To set Git Credential Manager Core for portable Git, please execute the following command:
git config --system credential.helper manager
PS C:\Users\USER> where.exe bash
C:\Users\USER\scoop\shims\bash.exe
複製此路徑後新增使用者變數 CLAUDE_CODE_GIT_BASH_PATH 並填入 bash 位置 :
完成後關閉 Power Shell 視窗重開, 這樣新增的環境變數才會生效.
2. 安裝 Claude Code :
開啟新的 PS 視窗, 輸入如下指令安裝 Claude Code :
PS C:\Users\USER> irm https://claude.ai/install.ps1 | iex
Setting up Claude Code...
✔ Claude Code successfully installed!
Version: 2.1.139
Location: C:\Users\USER\.local\bin\claude.exe
Next: Run claude --help to get started
⚠ Setup notes:
● Native installation exists but C:\Users\USER\.local\bin is not in your PATH. Add it by opening: System Properties →
Environment Variables → Edit User PATH → New → Add the path above. Then restart your terminal.
✅ Installation complete!
這樣便安裝好 Claude Code 了, 為了能在任何資料夾下使用 claude 指令, 須將 Claude Code 執行檔所在目錄 C:\Users\USER\.local\bin 加入環境變數 Path 中, 點選使用者變數 Path 按編輯鈕 :
按新增鈕後將上面的 Claude Code 執行檔安裝目錄 (注意不要包含執行檔, 只到 bin 目錄即可) C:\Users\USER\.local\bin 貼到新增欄位中按確定即可 :