-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdevice_id_win.ps1
47 lines (39 loc) · 1.56 KB
/
device_id_win.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Generate new IDs
$new_machine_id = -join ((1..64) | ForEach-Object { "0123456789abcdef"[(Get-Random -Max 16)] })
$new_dev_device_id = [guid]::NewGuid().ToString().ToLower()
$new_mac_machine_id = [guid]::NewGuid().ToString().ToLower()
$new_sqm_id = "{" + [guid]::NewGuid().ToString().ToUpper() + "}"
# File paths
$storage_json_path = "$env:APPDATA\Cursor\User\globalStorage\storage.json"
$backup_dir = "$env:APPDATA\Cursor\User\globalStorage\backups"
# Create backup directory if not exists
if (-not (Test-Path $backup_dir)) {
New-Item -ItemType Directory -Path $backup_dir | Out-Null
}
# Create backup with timestamp
$timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
$backup_path = Join-Path $backup_dir "storage_$timestamp.json"
# Backup existing file
if (Test-Path $storage_json_path) {
Copy-Item $storage_json_path $backup_path
Write-Host "Backup created: $backup_path"
}
# Update storage.json
if (Test-Path $storage_json_path) {
$content = Get-Content $storage_json_path -Raw | ConvertFrom-Json
} else {
$content = @{}
}
# Update all IDs
$content.'telemetry.machineId' = $new_machine_id
$content.'telemetry.devDeviceId' = $new_dev_device_id
$content.'telemetry.macMachineId' = $new_mac_machine_id
$content.'telemetry.sqmId' = $new_sqm_id
# Save changes
$content | ConvertTo-Json -Depth 100 | Out-File $storage_json_path -Encoding UTF8
# Display results
Write-Host "Successfully updated device IDs:"
Write-Host "machineId: $new_machine_id"
Write-Host "devDeviceId: $new_dev_device_id"
Write-Host "macMachineId: $new_mac_machine_id"
Write-Host "sqmId: $new_sqm_id"