跳到主要内容

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

浏览文件

install_windows.go

40 行 · 1.3 KB历史下载
1package guestos
2
3import (
4 "context"
5 "crypto/sha256"
6 "fmt"
7 "os"
8
9 "os/exec"
10 "path/filepath"
11
12 "github.com/sylvinus/agent-vm/internal/cage"
13 "golang.org/x/sys/windows"
14)
15
16func WindowsInstallCommand(ctx context.Context, profile, kit string, install Installation) (*exec.Cmd, error) {
17 system, err := windows.GetSystemDirectory()
18 if err != nil {
19 return nil, err
20 }
21 state, err := cage.StoragePhysicalPath(filepath.Join(profile, "state"))
22 if err != nil {
23 return nil, err
24 }
25 manifest, err := RequiredNativeComponents(kit, Windows11)
26 if err != nil {
27 return nil, err
28 }
29 manifestPath := filepath.Join(profile, "windows-components-required.json")
30 if err = WriteNativeComponentManifest(manifestPath, manifest); err != nil {
31 return nil, err
32 }
33 data, err := os.ReadFile(manifestPath)
34 if err != nil {
35 return nil, err
36 }
37 digest := fmt.Sprintf("%x", sha256.Sum256(data))
38 cmd := exec.CommandContext(ctx, filepath.Join(system, "WindowsPowerShell", "v1.0", "powershell.exe"), "-NoLogo", "-NoProfile", "-ExecutionPolicy", "RemoteSigned", "-File", filepath.Join(kit, "setup-windows-guest.ps1"), "-Profile", profile, "-State", state, "-InstallationID", install.ID.String(), "-IsoPath", install.Media, "-ExpectedIsoSha256", install.SHA256, "-ManifestPath", manifestPath, "-ManifestSHA256", digest)
39 return cmd, nil
40}