File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 打开'."
Original file line number Diff line number Diff line change 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."
You can’t perform that action at this time.
0 commit comments