<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jiří Štěpánek on Medium]]></title>
        <description><![CDATA[Stories by Jiří Štěpánek on Medium]]></description>
        <link>https://medium.com/@stepaji?source=rss-52b668d854c3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JMPj7dIJvefT83O4plw2HA.jpeg</url>
            <title>Stories by Jiří Štěpánek on Medium</title>
            <link>https://medium.com/@stepaji?source=rss-52b668d854c3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 12:17:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@stepaji/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Running Two Claude Desktop Instances Side by Side with SSO Sign-In]]></title>
            <link>https://medium.com/@stepaji/running-two-claude-desktop-instances-side-by-side-with-sso-sign-in-aab3668fd381?source=rss-52b668d854c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/aab3668fd381</guid>
            <category><![CDATA[multi-account]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[claude-desktop]]></category>
            <dc:creator><![CDATA[Jiří Štěpánek]]></dc:creator>
            <pubDate>Mon, 14 Sep 2026 09:23:40 GMT</pubDate>
            <atom:updated>2026-09-14T09:25:52.689Z</atom:updated>
            <content:encoded><![CDATA[<p><em>The usual multi-instance tricks break the moment your account signs in through SSO. Here is why, how a tiny protocol router fixes it, and a complete runbook, scripts included, that you or an AI agent can execute end to end on Windows 11.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kPK9vApKV76FyjqUH-Mgrw.png" /></figure><h3>The problem</h3><p>Claude Desktop has no account switcher. If you live in two Claude workspaces, say your employer’s SSO-managed one and a second one from a client or a side project, you keep signing out and in, or you keep one of them in the browser. On Windows the app is a single instance: launching it a second time only focuses the window you already have.</p><p>People have solved the “two windows” part before. This article is about the part nobody had solved for me: making the second window <strong>sign in through SSO</strong>.</p><h3>What already exists, and exactly where it stops working</h3><p>The known trick is to start the app a second time with a different profile folder. Claude Desktop is an Electron app and honours the Chromium switch --user-data-dir. A second profile means a second single-instance lock, a second window, separate conversations, settings and MCP configuration. A colleague of mine documented this for the Microsoft Store build, and there is a third-party Store app called <em>Multi Instance for Claude Desktop</em> that automates the same idea.</p><p>This works fine as long as you sign in with an <strong>email link</strong>: Claude mails you a link, you open it in a private browser window, you get a code, you type the code into the second window. Everything stays inside that window.</p><p><strong>SSO is different.</strong> You click <em>Continue with SSO</em>, the app opens your system browser, you authenticate with your identity provider, and at the very end the browser navigates to a link like this:</p><pre>claude://claude.ai/sso-callback?...</pre><p>That is a custom URL protocol. Windows looks up the registered handler for claude:// and starts it. The registered handler is the Claude app itself, with its <strong>default</strong> profile. So the callback always lands in the main window. The second window keeps waiting for a sign-in that already happened somewhere else. And because the callback is bound to the instance that started the flow (PKCE state), the main window cannot use it either; it just ignores it.</p><p>A launcher, however clever, cannot fix this. The third-party app does not touch the claude:// protocol at all (it only registers its own micd://). Whatever starts the second window, the SSO callback still goes to the first one.</p><h3>The fix in one sentence</h3><p>Put a small <strong>router</strong> between Windows and Claude: register it as the handler for claude://, and let it forward every incoming link to the right instance.</p><pre>browser  -&gt;  claude://claude.ai/sso-callback?...  -&gt;  Windows protocol handler<br>                                                        |<br>                                                  Claude router (PowerShell)<br>                                                        |<br>               one instance running?  -&gt; forward there  |   both running? -&gt; ask: Claude 1 / Claude 2<br>                                                        |<br>                    ActivateApplication(AUMID, &#39;--user-data-dir=...\Claude-2&#39; &#39;claude://...&#39;)<br>                                                        |<br>                       new claude.exe process -&gt; hands argv to the running Claude 2 -&gt; exits<br>                                                        |<br>                                         Claude 2 completes the sign-in</pre><p>The forwarding works because Electron’s second-instance mechanism passes the command line of a duplicate process to the instance that already owns that profile, and Claude Desktop scans that command line for claude: URLs. So &quot;deliver this link to Claude 2&quot; simply means &quot;start Claude with Claude 2&#39;s profile and the link as an argument&quot;.</p><h3>Six things you need to know before you build it</h3><p>I discovered all of these the hard way. If you only read one section, read this one.</p><ol><li><strong>A Store app cannot be started by path.</strong> The executable lives under C:\Program Files\WindowsApps\... and refuses to run directly. You start it through the COM interface IApplicationActivationManager::ActivateApplication(AUMID, arguments). The AUMID is &lt;PackageFamilyName&gt;!Claude; the package family name of the Store build is Claude_pzs8sxrjxfjjc on every machine (it is derived from the package name and the publisher). The scripts below still look it up dynamically.</li><li><strong>The link can be delivered as a command-line argument.</strong> Start the app with --user-data-dir=...\Claude-2 plus the URL. Within two or three seconds the new process attaches to the running Claude 2, hands over the arguments and exits. Claude 2&#39;s log then shows second-instance: .... Unknown links are ignored, which makes claude://router-test a safe self-test.</li><li><strong>The app’s own protocol registration never reaches the real registry.</strong> Claude Desktop calls setAsDefaultProtocolClient at every start and writes HKCU\Software\Classes\claude. In the Store build this write is <em>virtualized</em> (see point 4) and lands in the package container. The real key is therefore free for the router, and the app will not overwrite it. Once the router is registered, Windows sees two handlers for claude:// (the Store app and the router) and, having no user choice recorded, shows the &quot;How do you want to open this?&quot; dialog. The user choice (UserChoice in the registry) is protected by a hash; only the user can set it, by clicking <strong>Always</strong> in that dialog or in Settings. No script can do this step for you.</li><li><strong>Anything spawned by Claude Desktop is sandboxed by MSIX virtualization.</strong> This includes the shells that the <em>Code</em> tab (Claude Code inside Claude Desktop) runs, so it includes an AI agent working from there. Writes to %LOCALAPPDATA% and %APPDATA% silently go to %LOCALAPPDATA%\Packages\Claude_pzs8sxrjxfjjc\LocalCache\Local and ...\Roaming; writes to HKCU go to the package&#39;s private registry. Explorer, browsers, shortcuts and WMI never see them. The trap: GetCurrentPackageFullName in such a process reports &quot;no package&quot; (error 15700), so you cannot detect the sandbox through package identity. The reliable test is to write a file under %LOCALAPPDATA% and check whether WMI (CIM_DataFile) sees it. The escape is a process created through WMI (Win32_Process.Create), which runs unvirtualized, or simply a regular PowerShell window. The installer and uninstaller below detect the sandbox and refuse to run inside it.</li><li><strong>Where things physically live.</strong> The second profile: %LOCALAPPDATA%\Packages\Claude_pzs8sxrjxfjjc\LocalCache\Roaming\Claude-2. Claude 2&#39;s application logs: ...\LocalCache\Local\Claude-2\logs\main.log. The main instance&#39;s logs: %LOCALAPPDATA%\Claude\Logs\main.log. The router and its scripts: the real %LOCALAPPDATA%\Claude-2 (same name as the virtualized log folder, physically a different directory).</li><li><strong>Timing and cosmetics.</strong> Get-AppxPackage takes about half a second in Windows PowerShell 5.1 and compiling the small C# COM wrapper about one second, so a callback takes two to four seconds to arrive. The protocol handler runs through conhost.exe --headless powershell.exe ... so that no console window flashes (a Windows 11 feature). The <em>Claude 2</em> shortcut runs powershell.exe -WindowStyle Hidden with the shortcut set to &quot;minimized&quot;; a brief flicker is normal.</li></ol><p>Tested in September 2026 on Windows 11 Pro 24H2 with Claude Desktop 1.46388 and 1.49585 from the Microsoft Store; the app updated itself in between and nothing broke.</p><h3>What you get</h3><ul><li>A <strong>Claude 2</strong> shortcut on the Desktop and in the Start menu that opens a second window of the same installed app with its own profile. Both accounts stay signed in side by side.</li><li><strong>Claude router</strong>, the claude:// handler. One window running: the link goes there. Both running: a small dialog asks <em>Claude 1 / Claude 2</em>.</li><li>Everything in %LOCALAPPDATA%\Claude-2, written only to your user profile (HKCU). No admin rights.</li></ul><h3>Prerequisites</h3><ul><li>Windows 11 (for conhost --headless; on Windows 10 replace it with powershell.exe -WindowStyle Hidden in the installer&#39;s $routerCmd).</li><li>Claude Desktop installed from the <strong>Microsoft Store</strong>. The classic installer variant is discussed at the end.</li><li>Windows PowerShell 5.1 (built in). No admin rights, no extra software.</li></ul><h3>Step 1: check what you have</h3><p>Open a <strong>regular</strong> Windows PowerShell window (Win+X, Terminal). Not the Code tab inside Claude Desktop; see point 4 above.</p><pre>Get-AppxPackage -Name Claude | Select-Object Name, Version, PackageFamilyName<br>(Get-AppxPackage -Name Claude | Get-AppxPackageManifest).Package.Applications.Application.Id<br>reg query HKCU\Software\Classes\claude /s<br>reg query &quot;HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\claude&quot; /s</pre><p>Expected: a package with PackageFamilyName = Claude_pzs8sxrjxfjjc and application id Claude. If the first command prints nothing, you have the classic installer. Note the output of the last two commands; there may be leftovers of earlier experiments (mine pointed to a shim script that no longer existed). The installer backs up whatever it replaces.</p><h3>Step 2: create the folder and save the six files</h3><p>Create %LOCALAPPDATA%\Claude-2 and save the six files from the section <strong>The files</strong> below under exactly these names:</p><ul><li>Common.ps1</li><li>Launch-Claude-2.ps1</li><li>Claude-Router.ps1</li><li>Setup-Claude2.ps1</li><li>Remove-Claude2.ps1</li><li>Test-Router.cmd</li></ul><p>All of them are plain ASCII, so any editor and any encoding will do.</p><h3>Step 3: run the installer</h3><pre>powershell.exe -NoProfile -ExecutionPolicy Bypass -File &quot;$env:LOCALAPPDATA\Claude-2\Setup-Claude2.ps1&quot;</pre><p>It generates the icons from the Claude logo inside the package, creates the shortcuts, registers the router and finally prints how Windows will handle claude:// links now. On a fresh machine you will see:</p><pre>How Windows handles claude:// links now: C:\WINDOWS\system32\OpenWith.exe &quot;%1&quot;<br>ONE MANUAL STEP REMAINS (Windows does not let scripts do it):</pre><p>OpenWith.exe means Windows will ask you which app to use. That is expected. The installer is idempotent; run it again whenever you move the folder.</p><h3>Step 4: tell Windows to always use the router (one click)</h3><p>Double-click %LOCALAPPDATA%\Claude-2\Test-Router.cmd. Windows shows &quot;How do you want to open this?&quot; with two entries, <em>Claude</em> and <em>Claude router</em>. Pick <strong>Claude router</strong> and click <strong>Always</strong>. Not <em>Just once</em>: that records Undecided and the dialog comes back with every link. Then a message box appears: &quot;The claude:// router works.&quot;</p><p>Alternative: Settings &gt; Apps &gt; Default apps &gt; <strong>Claude router</strong> &gt; <strong>CLAUDE</strong> &gt; <em>Claude router</em>. This command opens that page directly:</p><pre>Start-Process &quot;ms-settings:defaultapps?registeredAppUser=ClaudeRouter&quot;</pre><p>To confirm the choice stuck, this must print the router command (something ending in Claude-Router.ps1&quot; &quot;%1&quot;), not OpenWith.exe:</p><pre>Add-Type -Namespace W -Name A -MemberDefinition &#39;[DllImport(&quot;shlwapi.dll&quot;, CharSet=CharSet.Unicode)] public static extern int AssocQueryString(int f, int s, string a, string e, System.Text.StringBuilder o, ref uint l);&#39;<br>$sb = New-Object Text.StringBuilder 2048; [uint32]$l = 2048; [W.A]::AssocQueryString(0x1000, 1, &#39;claude&#39;, &#39;open&#39;, $sb, [ref]$l) | Out-Null; $sb.ToString()</pre><h3>Step 5: sign in to Claude 2 through SSO</h3><ol><li>Start the <strong>Claude 2</strong> shortcut. A second, signed-out window opens. The main window can stay open.</li><li>In Claude 2 choose SSO sign-in and finish it in the browser.</li><li>The browser asks whether it may open <em>Claude router</em>. Allow it.</li><li>If both windows are running, the router asks which one should receive the link. Click <strong>Claude 2</strong>. If only Claude 2 is running, nothing is asked.</li><li>Claude 2 signs in. Its log (see point 5) shows claude.ai account active and logged in. If the first attempt does not complete, simply repeat from step 2; in my case the second attempt went through, the first callback had been delayed by the app-picker dialog.</li></ol><p>The same works for the main window; pick <em>Claude 1</em> in the dialog.</p><h3>The files</h3><p>Save each block under the name in its heading, into %LOCALAPPDATA%\Claude-2.</p><h3>Common.ps1</h3><pre># Claude-2 shared helpers: launching the Microsoft Store build of Claude Desktop with arguments<br>$ErrorActionPreference = &#39;Stop&#39;<br># --user-data-dir for Claude 2; MSIX redirects it physically to %LOCALAPPDATA%\Packages\Claude_*\LocalCache\Roaming\Claude-2<br>$script:Claude2DataDir    = Join-Path $env:APPDATA &#39;Claude-2&#39;<br>$script:ClaudePfnFallback = &#39;Claude_pzs8sxrjxfjjc&#39;<br>function Get-ClaudeAumid {<br>    $pkg = Get-AppxPackage -Name Claude -ErrorAction SilentlyContinue | Select-Object -First 1<br>    $pfn = if ($pkg) { $pkg.PackageFamilyName } else { $script:ClaudePfnFallback }<br>    &quot;$pfn!Claude&quot;<br>}<br>function Start-ClaudeApp {<br>    param([string[]]$ArgumentList = @())<br>    if (-not (&#39;ClaudeLauncher.AppLauncher&#39; -as [type])) {<br>        Add-Type -TypeDefinition @&#39;<br>using System;<br>using System.Runtime.InteropServices;<br>namespace ClaudeLauncher {<br>  public enum ActivateOptions { None = 0, DesignMode = 1, NoErrorUI = 2, NoSplashScreen = 4 }<br>  [ComImport, Guid(&quot;2e941141-7f97-4756-ba1d-9decde894a3d&quot;), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]<br>  public interface IApplicationActivationManager {<br>    [PreserveSig] int ActivateApplication([MarshalAs(UnmanagedType.LPWStr)] string appUserModelId, [MarshalAs(UnmanagedType.LPWStr)] string arguments, ActivateOptions options, out uint processId);<br>    [PreserveSig] int ActivateForFile([MarshalAs(UnmanagedType.LPWStr)] string appUserModelId, IntPtr itemArray, [MarshalAs(UnmanagedType.LPWStr)] string verb, out uint processId);<br>    [PreserveSig] int ActivateForProtocol([MarshalAs(UnmanagedType.LPWStr)] string appUserModelId, IntPtr itemArray, out uint processId);<br>  }<br>  [ComImport, Guid(&quot;45BA127D-10A8-46EA-8AB7-56EA9078943C&quot;)]<br>  public class ApplicationActivationManager { }<br>  public static class AppLauncher {<br>    public static uint Launch(string aumid, string arguments) {<br>      var mgr = (IApplicationActivationManager)new ApplicationActivationManager();<br>      uint pid;<br>      int hr = mgr.ActivateApplication(aumid, arguments, ActivateOptions.None, out pid);<br>      if (hr &lt; 0) Marshal.ThrowExceptionForHR(hr);<br>      return pid;<br>    }<br>  }<br>}<br>&#39;@<br>    }<br>    $argString = ($ArgumentList | ForEach-Object { &#39;&quot;&#39; + $_ + &#39;&quot;&#39; }) -join &#39; &#39;<br>    [ClaudeLauncher.AppLauncher]::Launch((Get-ClaudeAumid), $argString)<br>}<br>function Start-Claude2 {<br>    param([string[]]$ExtraArgs = @())<br>    Start-ClaudeApp -ArgumentList (@(&quot;--user-data-dir=$script:Claude2DataDir&quot;) + $ExtraArgs)<br>}</pre><h3>Launch-Claude-2.ps1</h3><pre># Claude 2: the same Store app with its own profile (--user-data-dir). Extra arguments (e.g. a claude:// URL) are passed to the app.<br>param([Parameter(ValueFromRemainingArguments = $true)][string[]]$ExtraArgs = @())<br>. &quot;$PSScriptRoot\Common.ps1&quot;<br>Start-Claude2 -ExtraArgs $ExtraArgs | Out-Null</pre><h3>Claude-Router.ps1</h3><pre># claude:// router - forwards a link coming from the browser (SSO callback etc.) to Claude 1 (default profile) or Claude 2.<br># If exactly one instance is running the link goes there; otherwise the user is asked.<br>param(<br>    [string]$Url = &#39;&#39;,<br>    [switch]$DryRun   # only print the decision; launch nothing, show nothing<br>)<br>. &quot;$PSScriptRoot\Common.ps1&quot;<br>Add-Type -AssemblyName System.Windows.Forms, System.Drawing<br>$logFile = Join-Path $PSScriptRoot &#39;router.log&#39;<br>function Write-RouterLog([string]$Message) {<br>    try {<br>        if ((Test-Path $logFile) -and (Get-Item $logFile).Length -gt 200KB) { Remove-Item $logFile -Force }<br>        Add-Content -Path $logFile -Value (&quot;{0:yyyy-MM-dd HH:mm:ss}  {1}&quot; -f (Get-Date), $Message) -Encoding UTF8<br>    } catch { }<br>}<br>function Get-SafeUrl([string]$u) { ($u -split &#39;[?#]&#39;, 2)[0] }   # no query/fragment - they carry authorization codesfunction Show-Message([string]$Text, [string]$Icon = &#39;Information&#39;) {<br>    [System.Windows.Forms.MessageBox]::Show($Text, &#39;Claude router&#39;, &#39;OK&#39;, $Icon) | Out-Null<br>}<br>function Show-ChoiceDialog([bool]$Running1, [bool]$Running2) {<br>    [System.Windows.Forms.Application]::EnableVisualStyles()<br>    $f = New-Object System.Windows.Forms.Form<br>    $f.Text = &#39;Claude router - where should this link go?&#39;<br>    $f.Size = New-Object System.Drawing.Size(460, 210)<br>    $f.StartPosition = &#39;CenterScreen&#39;<br>    $f.FormBorderStyle = &#39;FixedDialog&#39;<br>    $f.MaximizeBox = $false; $f.MinimizeBox = $false<br>    $f.TopMost = $true<br>    $f.Font = New-Object System.Drawing.Font(&#39;Segoe UI&#39;, 10)<br>    $ico = Join-Path $PSScriptRoot &#39;claude-router.ico&#39;<br>    if (Test-Path $ico) { $f.Icon = New-Object System.Drawing.Icon($ico) }<br>    $state = if ($Running1 -and $Running2) { &#39;Both Claude windows are running.&#39; }<br>             elseif (-not $Running1 -and -not $Running2) { &#39;No Claude window is running right now - the one you pick will be started.&#39; }<br>             else { &#39;&#39; }<br>    $lbl = New-Object System.Windows.Forms.Label<br>    $lbl.Text = &quot;Your browser is sending a claude:// link (typically the end of an SSO sign-in).`r`n$state`r`n`r`nWhich Claude window should receive it?&quot;<br>    $lbl.Location = New-Object System.Drawing.Point(16, 14)<br>    $lbl.Size = New-Object System.Drawing.Size(415, 90)<br>    $f.Controls.Add($lbl)<br>    $b1 = New-Object System.Windows.Forms.Button<br>    $b1.Text = &#39;Claude 1 (main)&#39;<br>    $b1.Location = New-Object System.Drawing.Point(40, 115); $b1.Size = New-Object System.Drawing.Size(170, 40)<br>    $b1.DialogResult = &#39;Yes&#39;<br>    $b2 = New-Object System.Windows.Forms.Button<br>    $b2.Text = &#39;Claude 2&#39;<br>    $b2.Location = New-Object System.Drawing.Point(240, 115); $b2.Size = New-Object System.Drawing.Size(170, 40)<br>    $b2.DialogResult = &#39;No&#39;<br>    $f.Controls.AddRange(@($b1, $b2))<br>    $f.AcceptButton = if ($Running2 -and -not $Running1) { $b2 } else { $b1 }<br>    switch ($f.ShowDialog()) { &#39;Yes&#39; { 1 } &#39;No&#39; { 2 } default { 0 } }<br>}<br>try {<br>    if (-not $Url) { Show-Message &quot;Usage: Claude-Router.ps1 claude://...`n`nWindows runs this script as the handler of the claude:// protocol.&quot; &#39;Warning&#39;; exit 1 }<br>    if ($Url -notmatch &#39;^claude:&#39;) { Show-Message &quot;Unsupported link: $(Get-SafeUrl $Url)&quot; &#39;Warning&#39;; exit 1 }<br>    if ($Url -match &#39;^claude://router-test&#39;) {<br>        if ($DryRun) { &#39;router-test&#39;; exit 0 }<br>        Write-RouterLog &#39;router-test OK&#39;<br>        Show-Message &quot;The claude:// router works.`n`nWindows now hands claude:// links to this router, which forwards them to Claude 1 or Claude 2.&quot;<br>        exit 0<br>    }<br>    $procs = Get-CimInstance Win32_Process -Filter &quot;Name=&#39;claude.exe&#39; OR Name=&#39;Claude.exe&#39;&quot; |<br>             Where-Object { $_.CommandLine -like &#39;*\WindowsApps\Claude_*&#39; }<br>    $running2 = [bool]($procs | Where-Object { $_.CommandLine -like &#39;*\Claude-2*&#39; })<br>    $running1 = [bool]($procs | Where-Object { $_.CommandLine -notlike &#39;*\Claude-2*&#39; })<br>    $target = if ($running1 -and -not $running2) { 1 }<br>              elseif ($running2 -and -not $running1) { 2 }<br>              elseif ($DryRun) { &#39;ask&#39; }<br>              else { Show-ChoiceDialog $running1 $running2 }<br>    if ($DryRun) { &quot;url=$(Get-SafeUrl $Url) running1=$running1 running2=$running2 target=$target&quot;; exit 0 }<br>    if ($target -eq 0) { Write-RouterLog &quot;cancelled by user: $(Get-SafeUrl $Url)&quot;; exit 0 }<br>    Write-RouterLog &quot;-&gt; Claude $target : $(Get-SafeUrl $Url) (running 1=$running1 2=$running2)&quot;<br>    if ($target -eq 2) { Start-Claude2 -ExtraArgs @($Url) | Out-Null }<br>    else               { Start-ClaudeApp -ArgumentList @($Url) | Out-Null }<br>}<br>catch {<br>    Write-RouterLog &quot;ERROR: $($_.Exception.Message)&quot;<br>    Show-Message &quot;Could not hand the link over to Claude:`n$($_.Exception.Message)&quot; &#39;Error&#39;<br>    exit 1<br>}</pre><h3>Setup-Claude2.ps1</h3><pre># Install / repair the second Claude Desktop instance (Microsoft Store build):<br># icons, &quot;Claude 2&quot; shortcuts (Desktop + Start menu) and registration of the claude:// link router.<br># Idempotent - safe to run again (e.g. after moving the folder). Writes only to the user profile (HKCU, %LOCALAPPDATA%).<br>$ErrorActionPreference = &#39;Stop&#39;<br>$dir = $PSScriptRoot<br>if (-not (&#39;ClaudeSetup.Native&#39; -as [type])) {<br>    Add-Type -Namespace ClaudeSetup -Name Native -MemberDefinition @&#39;<br>[DllImport(&quot;shell32.dll&quot;)] public static extern void SHChangeNotify(int eventId, uint flags, IntPtr item1, IntPtr item2);<br>[DllImport(&quot;shlwapi.dll&quot;, CharSet=CharSet.Unicode)] public static extern int AssocQueryString(int flags, int str, string assoc, string extra, System.Text.StringBuilder outBuf, ref uint outLen);<br>&#39;@<br>}<br># Run from a process under MSIX virtualization (e.g. the Code tab of Claude Desktop), writes to %LOCALAPPDATA% and HKCU<br># would end up in the package container, invisible to the browser and to shortcuts. Test: write a file, check it via WMI.<br>function Test-MsixVirtualized {<br>    $p = Join-Path $env:LOCALAPPDATA &quot;claude2-vtest-$PID.tmp&quot;<br>    Set-Content $p &#39;x&#39;<br>    try { $real = Get-CimInstance CIM_DataFile -Filter (&quot;Name=&#39;&quot; + $p.Replace(&#39;\&#39;, &#39;\\&#39;) + &quot;&#39;&quot;) -ErrorAction Stop } catch { $real = $true }<br>    Remove-Item $p -Force -ErrorAction SilentlyContinue<br>    -not $real<br>}<br>if (Test-MsixVirtualized) {<br>    throw &#39;This process is subject to Claude package (MSIX) virtualization - its writes would be invisible to the rest of Windows. Run the script from a regular PowerShell window, not from the Code tab in Claude Desktop.&#39;<br>}<br>$pkg = Get-AppxPackage -Name Claude | Select-Object -First 1<br>if (-not $pkg) { throw &#39;Claude Desktop (Microsoft Store build) is not installed for this user.&#39; }<br>foreach ($f in &#39;Common.ps1&#39;, &#39;Launch-Claude-2.ps1&#39;, &#39;Claude-Router.ps1&#39;) {<br>    if (-not (Test-Path &quot;$dir\$f&quot;)) { throw &quot;Missing file $dir\$f&quot; }<br>}<br>$ps      = &quot;$env:WINDIR\System32\WindowsPowerShell\v1.0\powershell.exe&quot;<br>$conhost = &quot;$env:WINDIR\System32\conhost.exe&quot;<br>$progId  = &#39;ClaudeRouter.claude&#39;<br>$appName = &#39;Claude router&#39;<br>$appDesc = &#39;Forwards claude:// links (e.g. the end of an SSO sign-in) to the Claude window of your choice - the main one or Claude 2.&#39;<br># ---- 1. icons (Claude logo from the package; Claude 2 gets a &quot;2&quot; badge) ------------------------------<br>Add-Type -AssemblyName System.Drawing<br>function New-ClaudeIcon([string]$Path, [bool]$Badge) {<br>    $src = [System.Drawing.Bitmap]::FromFile((Join-Path $pkg.InstallLocation &#39;assets\Square150x150Logo.scale-200.png&#39;))<br>    $out = New-Object System.Drawing.Bitmap 256, 256<br>    $g = [System.Drawing.Graphics]::FromImage($out)<br>    $g.InterpolationMode = &#39;HighQualityBicubic&#39;; $g.SmoothingMode = &#39;AntiAlias&#39;; $g.TextRenderingHint = &#39;AntiAliasGridFit&#39;<br>    $g.DrawImage($src, (New-Object System.Drawing.Rectangle 0, 0, 256, 256), (New-Object System.Drawing.Rectangle 14, 14, 272, 272), [System.Drawing.GraphicsUnit]::Pixel)<br>    if ($Badge) {<br>        $d = 108; $x = 256 - $d - 4; $y = 256 - $d - 4<br>        $g.FillEllipse([System.Drawing.Brushes]::White, $x - 7, $y - 7, $d + 14, $d + 14)<br>        $g.FillEllipse((New-Object System.Drawing.SolidBrush ([System.Drawing.Color]::FromArgb(255, 38, 38, 38))), $x, $y, $d, $d)<br>        $font = New-Object System.Drawing.Font(&#39;Segoe UI&#39;, 72, [System.Drawing.FontStyle]::Bold, [System.Drawing.GraphicsUnit]::Pixel)<br>        $sf = New-Object System.Drawing.StringFormat; $sf.Alignment = &#39;Center&#39;; $sf.LineAlignment = &#39;Center&#39;<br>        $g.DrawString(&#39;2&#39;, $font, [System.Drawing.Brushes]::White, (New-Object System.Drawing.RectangleF $x, ($y - 3), $d, $d), $sf)<br>    }<br>    $g.Dispose(); $src.Dispose()<br>    $ms = New-Object System.IO.MemoryStream<br>    $out.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png); $png = $ms.ToArray(); $out.Dispose()<br>    # ICO with a single 256x256 PNG image<br>    $fs = [System.IO.File]::Create($Path); $bw = New-Object System.IO.BinaryWriter($fs)<br>    $bw.Write([uint16]0); $bw.Write([uint16]1); $bw.Write([uint16]1)<br>    $bw.Write([byte]0); $bw.Write([byte]0); $bw.Write([byte]0); $bw.Write([byte]0)<br>    $bw.Write([uint16]1); $bw.Write([uint16]32); $bw.Write([uint32]$png.Length); $bw.Write([uint32]22); $bw.Write($png)<br>    $bw.Close()<br>}<br>New-ClaudeIcon &quot;$dir\claude-2.ico&quot; $true<br>New-ClaudeIcon &quot;$dir\claude-router.ico&quot; $false<br># ---- 2. &quot;Claude 2&quot; shortcuts -------------------------------------------------------------------------<br>$ws = New-Object -ComObject WScript.Shell<br>$shortcuts = @(<br>    (Join-Path ([Environment]::GetFolderPath(&#39;Desktop&#39;))  &#39;Claude 2.lnk&#39;),<br>    (Join-Path ([Environment]::GetFolderPath(&#39;Programs&#39;)) &#39;Claude 2.lnk&#39;)<br>)<br>foreach ($p in $shortcuts) {<br>    $s = $ws.CreateShortcut($p)<br>    $s.TargetPath       = $ps<br>    $s.Arguments        = &quot;-NoProfile -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -File `&quot;$dir\Launch-Claude-2.ps1`&quot;&quot;<br>    $s.WorkingDirectory = $dir<br>    $s.IconLocation     = &quot;$dir\claude-2.ico,0&quot;<br>    $s.Description      = &#39;Claude Desktop - second account (separate profile)&#39;<br>    $s.WindowStyle      = 7   # minimized console window so that nothing flashes<br>    $s.Save()<br>}<br># ---- 3. claude:// router registration (HKCU only) ---------------------------------------------------<br>function Ensure-Key([string]$Path) { if (-not (Test-Path $Path)) { New-Item -Path $Path -Force | Out-Null } }<br>$routerCmd = &quot;`&quot;$conhost`&quot; --headless `&quot;$ps`&quot; -NoProfile -NonInteractive -ExecutionPolicy Bypass -File `&quot;$dir\Claude-Router.ps1`&quot; `&quot;%1`&quot;&quot;<br>$icon = &quot;$dir\claude-router.ico,0&quot;<br>$k = &quot;HKCU:\Software\Classes\$progId&quot;<br>Ensure-Key &quot;$k\shell\open\command&quot;; Ensure-Key &quot;$k\DefaultIcon&quot;; Ensure-Key &quot;$k\Application&quot;<br>Set-ItemProperty $k -Name &#39;(default)&#39; -Value &quot;URL:$appName&quot;<br>Set-ItemProperty $k -Name &#39;URL Protocol&#39; -Value &#39;&#39;<br>Set-ItemProperty $k -Name &#39;FriendlyTypeName&#39; -Value $appName<br>Set-ItemProperty &quot;$k\DefaultIcon&quot; -Name &#39;(default)&#39; -Value $icon<br>Set-ItemProperty &quot;$k\shell\open&quot; -Name &#39;FriendlyAppName&#39; -Value $appName<br>Set-ItemProperty &quot;$k\shell\open\command&quot; -Name &#39;(default)&#39; -Value $routerCmd<br>Set-ItemProperty &quot;$k\Application&quot; -Name &#39;ApplicationName&#39; -Value $appName<br>Set-ItemProperty &quot;$k\Application&quot; -Name &#39;ApplicationDescription&#39; -Value $appDesc<br>Set-ItemProperty &quot;$k\Application&quot; -Name &#39;ApplicationIcon&#39; -Value $icon<br>$cap = &#39;HKCU:\Software\ClaudeRouter\Capabilities&#39;<br>Ensure-Key &quot;$cap\URLAssociations&quot;<br>Set-ItemProperty $cap -Name &#39;ApplicationName&#39; -Value $appName<br>Set-ItemProperty $cap -Name &#39;ApplicationDescription&#39; -Value $appDesc<br>Set-ItemProperty $cap -Name &#39;ApplicationIcon&#39; -Value $icon<br>Set-ItemProperty &quot;$cap\URLAssociations&quot; -Name &#39;claude&#39; -Value $progId<br>Ensure-Key &#39;HKCU:\Software\RegisteredApplications&#39;<br>Set-ItemProperty &#39;HKCU:\Software\RegisteredApplications&#39; -Name &#39;ClaudeRouter&#39; -Value &#39;Software\ClaudeRouter\Capabilities&#39;<br># Classic protocol key HKCU\Software\Classes\claude: the Store app writes it only into its virtualized registry,<br># so it never overwrites the real key. The previous value is saved to previous-claude-handler.txt.<br>$pk = &#39;HKCU:\Software\Classes\claude&#39;<br>Ensure-Key &quot;$pk\shell\open\command&quot;; Ensure-Key &quot;$pk\DefaultIcon&quot;; Ensure-Key &quot;$pk\OpenWithProgids&quot;<br>$prev = (Get-ItemProperty &quot;$pk\shell\open\command&quot; -ErrorAction SilentlyContinue).&#39;(default)&#39;<br>if ($prev -and $prev -ne $routerCmd) { Add-Content &quot;$dir\previous-claude-handler.txt&quot; (&quot;{0:yyyy-MM-dd HH:mm}  {1}&quot; -f (Get-Date), $prev) -Encoding UTF8 }<br>Set-ItemProperty $pk -Name &#39;(default)&#39; -Value &#39;URL:claude&#39;<br>Set-ItemProperty $pk -Name &#39;URL Protocol&#39; -Value &#39;&#39;<br>Set-ItemProperty &quot;$pk\DefaultIcon&quot; -Name &#39;(default)&#39; -Value $icon<br>Set-ItemProperty &quot;$pk\shell\open&quot; -Name &#39;FriendlyAppName&#39; -Value $appName<br>Set-ItemProperty &quot;$pk\shell\open\command&quot; -Name &#39;(default)&#39; -Value $routerCmd<br>Set-ItemProperty &quot;$pk\OpenWithProgids&quot; -Name $progId -Value &#39;&#39;<br># tell the shell that file/protocol associations changed<br>[ClaudeSetup.Native]::SHChangeNotify(0x08000000, 0x1000, [IntPtr]::Zero, [IntPtr]::Zero)<br># ---- 4. how Windows will actually handle claude:// links now -----------------------------------------<br>$sb = New-Object System.Text.StringBuilder 2048; [uint32]$len = 2048<br>$effective = if ([ClaudeSetup.Native]::AssocQueryString(0x1000, 1, &#39;claude&#39;, &#39;open&#39;, $sb, [ref]$len) -eq 0) { $sb.ToString() } else { &#39;(unknown)&#39; }<br>Write-Host &#39;&#39;<br>Write-Host &quot;Done. The &#39;Claude 2&#39; shortcut is on the Desktop and in the Start menu.&quot; -ForegroundColor Green<br>Write-Host &quot;How Windows handles claude:// links now: $effective&quot;<br>if ($effective -like &#39;*Claude-Router.ps1*&#39;) {<br>    Write-Host &#39;claude:// links go through Claude router - nothing else to do.&#39; -ForegroundColor Green<br>    Write-Host &quot;Verify: $dir\Test-Router.cmd&quot;<br>} else {<br>    Write-Host &#39;&#39;<br>    Write-Host &#39;ONE MANUAL STEP REMAINS (Windows does not let scripts do it):&#39; -ForegroundColor Yellow<br>    Write-Host &quot;  Run $dir\Test-Router.cmd - when Windows asks which app to use, pick &#39;Claude router&#39; and &#39;Always&#39;.&quot;<br>    Write-Host &#39;  Or: Settings &gt; Apps &gt; Default apps &gt; Claude router &gt; CLAUDE &gt; &quot;Claude router&quot;&#39;<br>    Write-Host &#39;      (opens with: Start-Process &quot;ms-settings:defaultapps?registeredAppUser=ClaudeRouter&quot;).&#39;<br>}</pre><h3>Remove-Claude2.ps1</h3><pre># Uninstall the second Claude instance: shortcuts, claude:// router registration and this folder.<br># The second account&#39;s profile (conversations, settings) is deleted only with -IncludeProfile.<br>param([switch]$IncludeProfile)<br>$ErrorActionPreference = &#39;Continue&#39;<br>$dir = $PSScriptRoot<br>$progId = &#39;ClaudeRouter.claude&#39;<br>if (-not (&#39;ClaudeSetup.Native&#39; -as [type])) {<br>    Add-Type -Namespace ClaudeSetup -Name Native -MemberDefinition &#39;[DllImport(&quot;shell32.dll&quot;)] public static extern void SHChangeNotify(int eventId, uint flags, IntPtr item1, IntPtr item2);&#39;<br>}<br>function Test-MsixVirtualized {<br>    $p = Join-Path $env:LOCALAPPDATA &quot;claude2-vtest-$PID.tmp&quot;<br>    Set-Content $p &#39;x&#39;<br>    try { $real = Get-CimInstance CIM_DataFile -Filter (&quot;Name=&#39;&quot; + $p.Replace(&#39;\&#39;, &#39;\\&#39;) + &quot;&#39;&quot;) -ErrorAction Stop } catch { $real = $true }<br>    Remove-Item $p -Force -ErrorAction SilentlyContinue<br>    -not $real<br>}<br>if (Test-MsixVirtualized) {<br>    throw &#39;This process is subject to Claude package (MSIX) virtualization - the changes would be invisible to the rest of Windows. Run the script from a regular PowerShell window, not from the Code tab in Claude Desktop.&#39;<br>}<br>foreach ($p in @((Join-Path ([Environment]::GetFolderPath(&#39;Desktop&#39;)) &#39;Claude 2.lnk&#39;), (Join-Path ([Environment]::GetFolderPath(&#39;Programs&#39;)) &#39;Claude 2.lnk&#39;))) {<br>    Remove-Item $p -Force -ErrorAction SilentlyContinue<br>}<br>Remove-Item &quot;HKCU:\Software\Classes\$progId&quot; -Recurse -Force -ErrorAction SilentlyContinue<br>Remove-Item &#39;HKCU:\Software\ClaudeRouter&#39; -Recurse -Force -ErrorAction SilentlyContinue<br>Remove-ItemProperty &#39;HKCU:\Software\RegisteredApplications&#39; -Name &#39;ClaudeRouter&#39; -ErrorAction SilentlyContinue<br>Remove-ItemProperty &#39;HKCU:\Software\Classes\claude\OpenWithProgids&#39; -Name $progId -ErrorAction SilentlyContinue<br># delete the classic protocol key only if it points to the router; Windows then falls back to the Store app registration<br>$pkCmd = (Get-ItemProperty &#39;HKCU:\Software\Classes\claude\shell\open\command&#39; -ErrorAction SilentlyContinue).&#39;(default)&#39;<br>if ($pkCmd -like &#39;*Claude-Router.ps1*&#39;) { Remove-Item &#39;HKCU:\Software\Classes\claude&#39; -Recurse -Force -ErrorAction SilentlyContinue }<br>$uc = &#39;HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\claude\UserChoice&#39;<br>if ((Test-Path $uc) -and ((Get-ItemProperty $uc).ProgId -eq $progId)) {<br>    Remove-Item $uc -Force -ErrorAction SilentlyContinue<br>    if (Test-Path $uc) { Write-Warning &#39;The default-app choice could not be removed - in Settings &gt; Apps &gt; Default apps set CLAUDE back to &quot;Claude&quot;.&#39; }<br>}<br>[ClaudeSetup.Native]::SHChangeNotify(0x08000000, 0x1000, [IntPtr]::Zero, [IntPtr]::Zero)<br>if ($IncludeProfile) {<br>    Get-CimInstance Win32_Process -Filter &quot;Name=&#39;claude.exe&#39; OR Name=&#39;Claude.exe&#39;&quot; |<br>        Where-Object { $_.CommandLine -like &#39;*\Claude-2*&#39; } |<br>        ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue }<br>    Start-Sleep -Seconds 2<br>    $profileDirs = @(&quot;$env:APPDATA\Claude-2&quot;) +<br>        (Get-ChildItem &quot;$env:LOCALAPPDATA\Packages\Claude_*\LocalCache\Roaming\Claude-2&quot;, &quot;$env:LOCALAPPDATA\Packages\Claude_*\LocalCache\Local\Claude-2&quot; -Directory -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName)<br>    foreach ($p in $profileDirs) {<br>        if (Test-Path $p) { Remove-Item $p -Recurse -Force -ErrorAction SilentlyContinue; Write-Host &quot;Deleted profile: $p&quot; }<br>    }<br>} else {<br>    Write-Host &#39;The second account profile was kept (delete it with -IncludeProfile).&#39;<br>}<br>Set-Location $env:USERPROFILE<br>Remove-Item $dir -Recurse -Force -ErrorAction SilentlyContinue<br>Write-Host &#39;Uninstall complete.&#39; -ForegroundColor Green</pre><h3>Test-Router.cmd</h3><pre>@echo off<br>rem Opens the test link claude://router-test - if &quot;Claude router&quot; is the default handler, a confirmation appears.<br>start &quot;&quot; &quot;claude://router-test&quot;</pre><h3>Verifying the installation</h3><ul><li><strong>Files</strong>: Get-ChildItem $env:LOCALAPPDATA\Claude-2 from a regular PowerShell shows the six files plus claude-2.ico and claude-router.ico.</li><li><strong>Shortcuts</strong>: on the Desktop and in %APPDATA%\Microsoft\Windows\Start Menu\Programs\Claude 2.lnk; target powershell.exe ... -File ...\Launch-Claude-2.ps1, icon with a &quot;2&quot; badge.</li><li><strong>Registry</strong>: reg query HKCU\Software\Classes\claude /s and reg query HKCU\Software\Classes\ClaudeRouter.claude /s both show a command starting with conhost.exe --headless and ending with Claude-Router.ps1&quot; &quot;%1&quot;.</li><li><strong>Effective handler</strong>: the AssocQueryString snippet from step 4 prints the router command. OpenWith.exe means the <em>Always</em> click is still missing.</li><li><strong>Router decision without side effects</strong>: powershell -ExecutionPolicy Bypass -File &quot;$env:LOCALAPPDATA\Claude-2\Claude-Router.ps1&quot; -Url claude://claude.ai/x -DryRun prints url=... running1=... running2=... target=1|2|ask.</li><li><strong>Second profile</strong>: after starting Claude 2, Get-CimInstance Win32_Process -Filter &quot;Name=&#39;claude.exe&#39;&quot; shows a main process with --user-data-dir=...\Claude-2, and the profile folder appears within ten seconds.</li><li><strong>Argument delivery to a running instance</strong>: . &quot;$env:LOCALAPPDATA\Claude-2\Common.ps1&quot;; Start-Claude2 -ExtraArgs &#39;claude://router-test&#39; produces Starting app, Not main instance, returning early and second-instance lines in Claude 2&#39;s log within five seconds; the app ignores the unknown link.</li><li><strong>End to end</strong>: Test-Router.cmd shows &quot;The claude:// router works.&quot; with no Windows dialog before it.</li></ul><h3>Troubleshooting</h3><ul><li><strong>“How do you want to open this?” appears at every link.</strong> No user choice recorded (you clicked <em>Just once</em>). Click <em>Always</em>, or set the default in Settings (step 4).</li><li><strong>The callback still lands in the main window and the router never runs.</strong> Either the installer ran inside a virtualized shell and the real registry never changed, or the user choice points at the Store app. Check AssocQueryString and reg query from a regular PowerShell, rerun the installer from a regular PowerShell, set the default app.</li><li><strong>Two “Claude router” entries in the picker.</strong> The classic protocol key and the ProgID point to the same command. Either one works.</li><li><strong>The router shows “Could not hand the link over to Claude”.</strong> ActivateApplication failed; the HRESULT is in the message. Check Get-AppxPackage -Name Claude in Windows PowerShell 5.1, restart the instance, read router.log.</li><li><strong>Claude 2 does not start from the shortcut.</strong> Usually the files are missing from the real folder because they were written from a virtualized shell. Check with Explorer or WMI, not from the Code tab.</li><li><strong>The installer stops with “This process is subject to Claude package (MSIX) virtualization”.</strong> Run it from a regular PowerShell window, or use the WMI escape described in the notes for agents.</li><li><strong>The installer fails while creating icons.</strong> It reads assets\Square150x150Logo.scale-200.png from the package; a future version may rename assets. Point New-ClaudeIcon at assets\icon.png (50 px) or any PNG.</li><li><strong>Where to look.</strong> Claude 2: %LOCALAPPDATA%\Packages\Claude_pzs8sxrjxfjjc\LocalCache\Local\Claude-2\logs\main.log. Claude 1: %LOCALAPPDATA%\Claude\Logs\main.log. Router: %LOCALAPPDATA%\Claude-2\router.log (URLs are logged without their query string, because the query string carries authorization codes). Search for [Auth], [account], second-instance, logged in. Do not paste the application logs anywhere public without stripping URLs.</li></ul><h3>Uninstall</h3><pre>powershell.exe -NoProfile -ExecutionPolicy Bypass -File &quot;$env:LOCALAPPDATA\Claude-2\Remove-Claude2.ps1&quot;                   # shortcuts, registry, scripts<br>powershell.exe -NoProfile -ExecutionPolicy Bypass -File &quot;$env:LOCALAPPDATA\Claude-2\Remove-Claude2.ps1&quot; -IncludeProfile  # also the second profile and its logs</pre><p>The classic protocol key is removed only if it points at the router, the user choice only if it points at ClaudeRouter.claude. Afterwards claude:// links go to the Store app again.</p><h3>Handing this article to an AI agent</h3><p>I did not type any of this by hand. I asked Claude Code to build it, and it discovered along the way that it was being sandboxed by the very app it was running in (point 4). The article is written so that another agent can reproduce the setup from the text alone, without any downloads. A prompt that works:</p><blockquote><em>Here is an article that contains a complete runbook and all scripts. Reproduce the setup on this machine. Follow the section “Notes for AI agents” strictly. Do not sign in on my behalf; stop and tell me when I have to click “Always”.</em></blockquote><p>Paste the article text (or give the agent the URL) together with that prompt. If the agent runs in a regular terminal, it can simply follow steps 1 to 4. If it runs inside Claude Desktop’s Code tab, it must use the WMI escape below.</p><h3>Notes for AI agents</h3><p><strong>1. Detect the sandbox first.</strong> Write a file under %LOCALAPPDATA% and check whether WMI sees it:</p><pre>$p = &quot;$env:LOCALAPPDATA\vtest-$PID.tmp&quot;; Set-Content $p x<br>[bool](Get-CimInstance CIM_DataFile -Filter (&quot;Name=&#39;&quot; + $p.Replace(&#39;\&#39;,&#39;\\&#39;) + &quot;&#39;&quot;))   # False = you are virtualized</pre><p>Do not trust GetCurrentPackageFullName (it returns 15700 even when virtualized), and do not trust Test-Path or reg query from your own shell for verification; they show a merged view of the overlay and the real system. Verify through WMI: CIM_DataFile for files, StdRegProv for registry values.</p><p><strong>2. Escape through WMI when virtualized.</strong> Write the six files and a small bootstrap script to a location that is real from both sides (the Desktop works; %TEMP% does not, it is virtualized too). Then:</p><pre>$cmd = &quot;`&quot;$env:WINDIR\System32\WindowsPowerShell\v1.0\powershell.exe`&quot; -NoProfile -NonInteractive -ExecutionPolicy Bypass -File `&quot;&lt;desktop&gt;\bootstrap.ps1`&quot; `&quot;&lt;desktop&gt;\out.txt`&quot;&quot;<br>$r = Invoke-CimMethod -ClassName Win32_Process -MethodName Create -Arguments @{ CommandLine = $cmd; CurrentDirectory = $env:USERPROFILE }<br>Wait-Process -Id $r.ProcessId -Timeout 180 -ErrorAction SilentlyContinue; Get-Content &quot;&lt;desktop&gt;\out.txt&quot;</pre><p>The bootstrap copies the files into %LOCALAPPDATA%\Claude-2, runs Setup-Claude2.ps1 in a child powershell.exe and writes all output to the out file. Processes created this way run unvirtualized in the user&#39;s interactive session. Afterwards delete any copies that ended up in the overlay (%LOCALAPPDATA%\Packages\Claude_pzs8sxrjxfjjc\LocalCache\Local\Claude-2\*.ps1 and friends), but leave its logs subfolder alone; it belongs to Claude 2.</p><p><strong>3. Never sign in for the user.</strong> Verify with -DryRun, with Start-Claude2 -ExtraArgs &#39;claude://router-test&#39; (look for second-instance in Claude 2&#39;s log), with WMI checks of files and registry.</p><p><strong>4. The default-app choice is the user’s click.</strong> Bring up the picker from an unvirtualized process, Invoke-CimMethod -ClassName Win32_Process -MethodName Create -Arguments @{ CommandLine = &#39;cmd.exe /c start &quot;&quot; &quot;claude://router-test&quot;&#39; }, then tell the user to pick <em>Claude router</em> and <em>Always</em>. Confirm by reading UrlAssociations\claude\UserChoice\ProgId through StdRegProv.</p><p><strong>5. Sanitize logs</strong> before showing them; strip everything from ? onwards in URLs.</p><p><strong>6. Never edit the installed scripts from a virtualized shell.</strong> The edit creates a hidden overlay copy and the installed version stays unchanged.</p><p><strong>7. Done means</strong>: files physically present, both registry keys pointing at the router, shortcuts present, AssocQueryString returning the router command (or the user informed about the <em>Always</em> click), Claude 2 starting with its own profile.</p><h3>Limitations</h3><ul><li>Both windows belong to one Store app, so the taskbar groups them under one icon. Pin the <em>Claude 2</em> shortcut yourself (right-click &gt; Pin to taskbar); Windows does not let scripts do that.</li><li>The <em>Code</em> tab (Claude Code) shares ~\.claude (settings, memory, session history) between both instances. The CLI sign-in comes from each window&#39;s own session, but the history mixes.</li><li>The scripts assume exactly two instances. A third one is a matter of parameterizing the profile name, but the router’s dialog and detection would need a third button and a third pattern.</li><li><strong>Classic installer (not Store), untested.</strong> The executable is usually %LOCALAPPDATA%\AnthropicClaude\claude.exe and can be started directly with --user-data-dir (no COM activation needed). But that build is not virtualized, so it really does overwrite HKCU\Software\Classes\claude at every start; the router must then win through the ProgID ClaudeRouter.claude plus the user choice, and the installer&#39;s block that writes the classic key should be skipped. In the router, replace the process filter *\WindowsApps\Claude_* with the path of the executable; the \Claude-2 marker works the same.</li><li>This is not affiliated with Anthropic. The scripts touch only your own user profile and are short enough to read before you run them, which you should do.</li></ul><h3>Closing</h3><p>The multi-profile trick has been around for a while. What SSO adds is a hop through the operating system’s protocol handler, and that hop is where every existing solution silently drops the ball. A hundred lines of PowerShell in the right place pick it up again. If you improve on this, especially the classic-installer variant, I would love to hear about it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aab3668fd381" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>