-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.ps1
More file actions
69 lines (57 loc) · 2.92 KB
/
Copy pathinstall.ps1
File metadata and controls
69 lines (57 loc) · 2.92 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
$appName = "cursorx"
$packageName = "cursorscript"
$installDir = "$HOME\.$packageName"
$url = "https://github.com/naveenpoddar/cursorscript/releases/latest/download/cursorscript-windows-x64-baseline.zip"
# 0. Stop the application if it's currently running
if (Get-Process -Name $appName -ErrorAction SilentlyContinue) {
Write-Host "🛑 Stopping running instance of $appName..." -ForegroundColor Yellow
Stop-Process -Name $appName -Force
Start-Sleep -Seconds 1 # Give Windows a brief moment to release the file locks
}
# 1. Prepare Directory
if (Test-Path $installDir) {
Write-Host "🗑️ Removing existing $installDir..." -ForegroundColor Yellow
Remove-Item -Path $installDir -Recurse -Force
}
New-Item -ItemType Directory -Path $installDir -Force
# 2. Download and Extract
Write-Host "📥 Downloading latest build..." -ForegroundColor Cyan
Invoke-WebRequest -Uri $url -OutFile "$installDir\build.zip"
Write-Host "📦 Extracting all files..." -ForegroundColor Cyan
# Extract to a temp folder first to handle the nested directory structure
$tempDir = Join-Path $installDir "temp"
Expand-Archive -Path "$installDir\build.zip" -DestinationPath $tempDir -Force
# 3. Move the .exe to the root of $installDir
# This assumes cursorx.exe is inside the nested folder in the ZIP
Get-ChildItem -Path "$tempDir\*\*" | Move-Item -Destination $installDir -Force
# Cleanup temp files
Remove-Item -Path $tempDir, "$installDir\build.zip" -Recurse -Force
# 4. Add to Path (User Level)
Write-Host "⚙️ Adding $installDir to Path..." -ForegroundColor Cyan
$oldPath = [Environment]::GetEnvironmentVariable("Path", "User")
# Check if the path is already there to avoid duplicates
if ($oldPath -split ';' -notcontains $installDir) {
$newPath = "$oldPath;$installDir".TrimEnd(';')
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")
$env:Path = "$env:Path;$installDir" # Update current session immediately
Write-Host "✅ Path updated successfully." -ForegroundColor Green
}
else {
Write-Host "ℹ️ Path already exists in environment variables." -ForegroundColor Yellow
}
Write-Host "✨ Done! All files are in $installDir" -ForegroundColor Green
# 5. Set High Performance Graphics Preference (Windows Registry)
Write-Host "🎮 Setting High Performance Graphics Preference..." -ForegroundColor Cyan
$registryPath = "HKCU:\Software\Microsoft\DirectX\UserGpuPreferences"
$exePath = "$installDir\cursorx.exe"
try {
if (!(Test-Path $registryPath)) {
New-Item -Path $registryPath -Force | Out-Null
}
# GpuPreference=2; means High Performance
Set-ItemProperty -Path $registryPath -Name $exePath -Value "GpuPreference=2;" -ErrorAction Stop
Write-Host "🚀 High Performance mode enabled for $appName." -ForegroundColor Green
} catch {
Write-Host "⚠️ Could not set graphics preference: $($_.Exception.Message)" -ForegroundColor Yellow
}
Write-Host "👉 Restart your terminal and type '$appName' to begin."