This repository was archived by the owner on Jul 22, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstall-Shortcut.ps1
More file actions
50 lines (43 loc) · 1.73 KB
/
Copy pathInstall-Shortcut.ps1
File metadata and controls
50 lines (43 loc) · 1.73 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
#Requires -Version 5.1
<#
.SYNOPSIS
Creates Desktop + Start Menu shortcuts for OpenCode Desktop.
#>
[CmdletBinding()]
param(
[switch]$StartMenuOnly,
[string]$Project = ""
)
$ErrorActionPreference = "Stop"
$AppRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
$Target = Join-Path $AppRoot "Start-OpenCode-Silent.vbs"
$WorkDir = if ($Project -and (Test-Path $Project)) { $Project } else { $env:USERPROFILE }
if (-not (Test-Path $Target)) {
throw "Missing launcher: $Target"
}
# Use the user's actual OpenCode icon so the launcher/pinned taskbar shortcut has the correct mark.
$icon = Join-Path $AppRoot "assets\opencode-desktop.ico"
if (-not (Test-Path $icon)) {
throw "Missing OpenCode icon: $icon"
}
function New-Shortcut([string]$Path, [string]$Args = "") {
$wsh = New-Object -ComObject WScript.Shell
$lnk = $wsh.CreateShortcut($Path)
$lnk.TargetPath = "wscript.exe"
$lnk.Arguments = "`"$Target`"" + $(if ($Args) { " $Args" } else { "" })
$lnk.WorkingDirectory = $WorkDir
$lnk.WindowStyle = 1
$lnk.Description = "OpenCode Desktop - local web UI in an app window"
$lnk.IconLocation = $icon
$lnk.Save()
Write-Host "Created: $Path" -ForegroundColor Green
}
$desktop = [Environment]::GetFolderPath("Desktop")
$startMenu = Join-Path $env:APPDATA "Microsoft\Windows\Start Menu\Programs"
if (-not $StartMenuOnly) {
New-Shortcut -Path (Join-Path $desktop "OpenCode Desktop.lnk")
}
New-Shortcut -Path (Join-Path $startMenu "OpenCode Desktop.lnk")
Write-Host ""
Write-Host "Done. Double-click 'OpenCode Desktop' on your Desktop to launch." -ForegroundColor Cyan
Write-Host "App folder: $AppRoot" -ForegroundColor DarkGray