使用方法
- 在桌面新建一个文本文档,
- 粘贴以下代码保存,
- 重命名为 index.ps1
- 右键,选择 使用powerShell运行。
- 之后即可正常注册使用cursor。
# 生成新的 UUID 并转换为小写
$new_machine_id = [guid]::NewGuid().ToString().ToLower()
$new_dev_device_id = [guid]::NewGuid().ToString().ToLower()
# 生成 32 字节的随机十六进制字符串
$new_mac_machine_id = -join ((1..32) | ForEach-Object { "{0:x}" -f (Get-Random -Max 16) })
# 定义文件路径
$machine_id_path = "$env:APPDATA\Cursor\machineid"
$storage_json_path = "$env:APPDATA\Cursor\User\globalStorage\storage.json"
# 备份原始文件
Copy-Item $machine_id_path "$machine_id_path.backup" -ErrorAction SilentlyContinue
Copy-Item $storage_json_path "$storage_json_path.backup" -ErrorAction SilentlyContinue
# 更新 machineid 文件
$new_machine_id | Out-File -FilePath $machine_id_path -Encoding UTF8 -NoNewline
# 读取并更新 storage.json 文件
$content = Get-Content $storage_json_path -Raw | ConvertFrom-Json
$content.'telemetry.devDeviceId' = $new_dev_device_id
$content.'telemetry.macMachineId' = $new_mac_machine_id
# 保存更新后的 storage.json 文件
$content | ConvertTo-Json -Depth 100 | Out-File $storage_json_path -Encoding UTF8
评论 (0)