Skip to content

Commit bd17645

Browse files
committed
ci: add Windows context-menu helper scripts to repo (required by portable zip build)
1 parent d6acb29 commit bd17645

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

scripts/register-context-menu.ps1

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Register "Open in GenCode" on folder/drive right-click (portable / manual install).
2+
# Run from the folder that contains gencode.exe, or pass -ExePath explicitly.
3+
4+
param(
5+
[string]$ExePath = (Join-Path $PSScriptRoot "gencode.exe")
6+
)
7+
8+
$ErrorActionPreference = "Stop"
9+
10+
if (-not (Test-Path -LiteralPath $ExePath)) {
11+
Write-Error "gencode.exe not found: $ExePath"
12+
}
13+
14+
$ExePath = (Resolve-Path -LiteralPath $ExePath).Path
15+
$quotedExe = "`"$ExePath`""
16+
$icon = "`"$ExePath`",0"
17+
$command = "$quotedExe `"%V`""
18+
19+
$targets = @(
20+
"HKCU:\Software\Classes\Directory\shell\OpenInGenCode",
21+
"HKCU:\Software\Classes\Directory\Background\shell\OpenInGenCode",
22+
"HKCU:\Software\Classes\Drive\shell\OpenInGenCode"
23+
)
24+
25+
foreach ($base in $targets) {
26+
New-Item -Path $base -Force | Out-Null
27+
Set-ItemProperty -Path $base -Name "(default)" -Value "用 GenCode 打开"
28+
Set-ItemProperty -Path $base -Name "Icon" -Value $icon
29+
Set-ItemProperty -Path $base -Name "NoWorkingDirectory" -Value ""
30+
New-Item -Path "$base\command" -Force | Out-Null
31+
Set-ItemProperty -Path "$base\command" -Name "(default)" -Value $command
32+
}
33+
34+
Write-Host "Registered context menu for: $ExePath"
35+
Write-Host "Right-click a folder in Explorer and choose '用 GenCode 打开'."
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Remove "Open in GenCode" Explorer context menu entries.
2+
3+
$ErrorActionPreference = "Stop"
4+
5+
$targets = @(
6+
"HKCU:\Software\Classes\Directory\shell\OpenInGenCode",
7+
"HKCU:\Software\Classes\Directory\Background\shell\OpenInGenCode",
8+
"HKCU:\Software\Classes\Drive\shell\OpenInGenCode"
9+
)
10+
11+
foreach ($base in $targets) {
12+
if (Test-Path -LiteralPath $base) {
13+
Remove-Item -LiteralPath $base -Recurse -Force
14+
}
15+
}
16+
17+
Write-Host "Removed GenCode Explorer context menu entries."

0 commit comments

Comments
 (0)