Skip to content

statusline.ps1 fails silently on Windows when PowerShell ExecutionPolicy blocks unsigned scripts #25

@SacrilegeTx

Description

@SacrilegeTx

Description

When following the Manual setup — Windows instructions in the README, the status line fails to appear in Claude Code. The failure is silent — Claude Code does not surface the error, so from the user's perspective nothing happens at all.

Running the documented command manually reveals the real cause:

File C:\Users\<user>\.claude\statusline.ps1 cannot be loaded because running scripts is disabled on this system.
For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
    + CategoryInfo          : SecurityError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnauthorizedAccess

Root cause

The README's Windows command is:

"command": "powershell -NoProfile -File \"%USERPROFILE%\.claude\statusline.ps1\""

This does not pass -ExecutionPolicy Bypass. If the machine's PowerShell ExecutionPolicy is set to Restricted, AllSigned, or in some misconfigured states of RemoteSigned, the .ps1 script is refused because it is unsigned. This is a common default — especially in corporate environments where Group Policy enforces Restricted or AllSigned.

Because Claude Code invokes the status line as a background command and does not display its stderr, the user only sees "nothing happens" with no hint as to why.

Additional issue — %USERPROFILE% no longer reliable on Claude Code v2.1.47+

According to recent Claude Code release notes, starting from v2.1.47 Unix-style path parsing is supported on Windows and the ~ symbol is automatically expanded to the user home directory. The note explicitly recommends not using %USERPROFILE% anymore, as it no longer works reliably in v2.1.47+.

The README still shows %USERPROFILE%\.claude\statusline.ps1, which is now a second source of failure on modern Claude Code versions — independent from the ExecutionPolicy issue.

Reproduction

  1. Fresh Windows 10/11 install (or any Windows with restrictive ExecutionPolicy).
  2. Follow the Manual setup — Windows instructions from the README verbatim.
  3. Restart Claude Code.
  4. Expected: status line appears. Actual: no status line, no error.

Manually running the same command from a shell surfaces the UnauthorizedAccess / running scripts is disabled error.

Suggested fix

Update the Windows command in the README to:

  1. Add -ExecutionPolicy Bypass (process-scoped — does not modify the machine's policy, so it is safe and non-invasive).
  2. Replace %USERPROFILE%\.claude\statusline.ps1 with ~/.claude/statusline.ps1 (Unix-style, works on Claude Code v2.1.47+).
  3. Prefer pwsh (PowerShell 7+) when available — it is the actively developed cross-platform PowerShell. Fall back to powershell (Windows PowerShell 5.1) for users who have not installed PS7.

Recommended (PowerShell 7+):

"command": "pwsh -NoProfile -ExecutionPolicy Bypass -File ~/.claude/statusline.ps1"

Fallback (Windows PowerShell 5.1):

"command": "powershell -NoProfile -ExecutionPolicy Bypass -File ~/.claude/statusline.ps1"

This has been tested end-to-end on Windows 11 + PowerShell 7 + Claude Code 2.1.116 and works.

A short troubleshooting note in the README would also help users who hit restrictive corporate policies or who want to understand why -ExecutionPolicy Bypass is required.

Environment

  • Windows 11 Enterprise (26100)
  • PowerShell 5.1 (default) and PowerShell 7 (optional)
  • Claude Code 2.1.116
  • statusline.ps1 version 1.3.0

Happy to send a PR with the README update if that is useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions