跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

test-windows-guest-powershell.cmd

23 行 · 2.5 KB历史下载
1@echo off
2setlocal EnableExtensions DisableDelayedExpansion
3rem Run in a fresh standard-user session after Windows Setup. Set
4rem CAGE_QA_EXPECTED_VM_ID to the GUID read independently from Get-VM on the host.
5rem In guest PowerShell, set $env:CAGE_QA_EXPECTED_VM_ID before running this file.
6"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -Command ^
7 "$ErrorActionPreference = 'Stop';" ^
8 "$expected = [guid]::Empty; if (![guid]::TryParse($env:CAGE_QA_EXPECTED_VM_ID, [ref]$expected) -or $expected -eq [guid]::Empty) { throw 'Supply a host-verified VM GUID.' }" ^
9 "$system = Get-CimInstance Win32_ComputerSystem;" ^
10 "if ($system.Manufacturer -ne 'Microsoft Corporation' -or $system.Model -ne 'Virtual Machine') { throw 'Run this check inside the selected Hyper-V guest.' }" ^
11 "$actual = Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters' -Name VirtualMachineId;" ^
12 "if ([guid]$actual -ne $expected) { throw 'The guest differs from the host-verified VM ID.' }" ^
13 "$identity = [Security.Principal.WindowsIdentity]::GetCurrent();" ^
14 "$groups = & (Join-Path $env:SystemRoot 'System32\whoami.exe') /groups /fo csv /nh;" ^
15 "if (!$groups -or $LASTEXITCODE -ne 0 -or $identity.IsSystem -or $groups -match '\bS-1-5-32-544\b') { throw 'Sign in as a standard guest user outside the Administrators group.' }" ^
16 "$legacy = $PSVersionTable.PSVersion;" ^
17 "if ($PSVersionTable.PSEdition -ne 'Desktop' -or $legacy.Major -ne 5 -or $legacy.Minor -ne 1) { throw 'Expected the system Windows PowerShell 5.1.' }" ^
18 "$command = Get-Command pwsh; $expectedExe = Join-Path ([Environment]::GetFolderPath('ProgramFiles')) 'PowerShell\7\pwsh.exe';" ^
19 "if ($command.CommandType -ne 'Application' -or $command.Path -ne $expectedExe) { throw 'The user PATH does not resolve pwsh to the installed shell.' }" ^
20 "$probe = @(pwsh -NoLogo -NoProfile -NonInteractive -Command '$PSVersionTable.PSEdition; $PSVersionTable.PSVersion.ToString(); [Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString()');" ^
21 "if ($LASTEXITCODE -ne 0 -or $probe.Count -ne 3 -or $probe[0] -ne 'Core' -or $probe[1] -notmatch '^7\.[0-9]+\.[0-9]+$' -or $probe[2] -ne 'X64') { throw 'Expected a working x64 PowerShell 7 release.' }" ^
22 "[pscustomobject]@{ VMId = $expected; User = $identity.Name; WindowsPowerShell = $legacy.ToString(); PowerShell = $probe[1]; Architecture = $probe[2]; Executable = $command.Path } | ConvertTo-Json -Compress"
23exit /b %errorlevel%