Skip to content

Commit bf430d6

Browse files
fix(windows scripts): parser error + non-ASCII under Windows PowerShell 5.1
- context-menu-manager: the toggle message used a nested $(if ...) inside a -f array, which Windows PowerShell 5.1 refuses to parse (reported as an unexpected } on the next line). Extracted it to a $action variable. - Replace all non-ASCII (em dashes, ellipses, bullets, arrows, box chars) with ASCII across every Windows .ps1/.cmd/.vbs: 5.1 reads BOM-less files as ANSI, so those bytes would render as mojibake (and risk mis-parsing).
1 parent 4ea89b7 commit bf430d6

8 files changed

Lines changed: 30 additions & 29 deletions

scripts/mount-opencoperlock-windows.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@echo off
22
REM ===========================================================================
3-
REM OpenCoperLock one-click WebDAV mount for Windows.
3+
REM OpenCoperLock - one-click WebDAV mount for Windows.
44
REM Double-click this file. It runs the PowerShell script next to it, which
55
REM configures Windows' WebClient service (a UAC prompt will appear) and maps
66
REM your Drive to a drive letter.

scripts/mount-opencoperlock-windows.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
<#
2-
OpenCoperLock mount your Drive as a Windows network drive over WebDAV.
2+
OpenCoperLock - mount your Drive as a Windows network drive over WebDAV.
33
44
Windows' built-in WebDAV client (the "WebClient" service) needs a few registry tweaks before it
55
behaves, and it mislabels the mount. This script does the whole thing in one shot:
66
77
1. Configures the WebClient service (Basic-over-HTTPS, raises the 50 MB download cap, longer
8-
timeout) this part self-elevates to Administrator.
8+
timeout) - this part self-elevates to Administrator.
99
2. Restarts WebClient so the settings take effect and its "not a WebDAV server" cache is cleared.
1010
3. Maps your Drive to a drive letter (default X:) that reconnects at logon.
1111
4. Gives the drive a proper label instead of Windows' ugly default ("dav").
1212
13-
USAGE (right-click the .cmd wrapper it calls this, or run directly):
13+
USAGE (right-click the .cmd wrapper -> it calls this, or run directly):
1414
1515
powershell -ExecutionPolicy Bypass -File .\mount-opencoperlock-windows.ps1 `
1616
-Server copper.forgenet.fr -Drive X -Token ocl_XXXXXXXX -Label "OpenCoperLock"
1717
18-
The token is your PERSONAL API token (Account API tokens) an unrestricted one; folder-scoped
18+
The token is your PERSONAL API token (Account -> API tokens) - an unrestricted one; folder-scoped
1919
tokens are refused by WebDAV. If you omit -Token the script prompts for it.
2020
2121
NOTE ON "free space": Windows often shows your LOCAL C: drive's size on a WebDAV mount instead of
22-
your account quota. That's a Windows limitation the server does report the correct quota. Your
22+
your account quota. That's a Windows limitation - the server does report the correct quota. Your
2323
real usage is always shown in the web app.
2424
#>
2525
[CmdletBinding()]
@@ -43,7 +43,7 @@ function Test-Admin {
4343
[Security.Principal.WindowsBuiltinRole]::Administrator)
4444
}
4545

46-
# ── Phase A: the Administrator-only part (registry + service) ─────────────────────────────────
46+
# -- Phase A: the Administrator-only part (registry + service) ---------------------------------
4747
function Set-WebClientConfig {
4848
$p = "HKLM:\SYSTEM\CurrentControlSet\Services\WebClient\Parameters"
4949
Set-ItemProperty $p -Name BasicAuthLevel -Value 2 -Type DWord
@@ -60,7 +60,7 @@ if ($ConfigureOnly) {
6060
return
6161
}
6262

63-
# ── Phase B: the normal-user part (mapping must NOT run elevated, or Explorer won't see it) ─────
63+
# -- Phase B: the normal-user part (mapping must NOT run elevated, or Explorer won't see it) -----
6464
if (-not $Token) { $Token = Read-Host "Paste your OpenCoperLock API token (ocl_...)" }
6565
if (-not $Token) { throw "No token provided." }
6666

@@ -96,5 +96,5 @@ try {
9696
}
9797

9898
Write-Host ""
99-
Write-Host "Done. Your Drive is mounted at $($Drive): open 'This PC'." -ForegroundColor Green
99+
Write-Host "Done. Your Drive is mounted at $($Drive): - open 'This PC'." -ForegroundColor Green
100100
Write-Host "(Windows may show your local disk size for 'free space'; that's a Windows quirk, not your real quota.)" -ForegroundColor DarkGray

scripts/send-to/windows/install-windows.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@echo off
22
REM ===========================================================================
3-
REM OpenCoperLock install "Send to > OpenCoperLock" (Windows, no admin).
3+
REM OpenCoperLock - install "Send to > OpenCoperLock" (Windows, no admin).
44
REM Double-click this file. You'll be asked for your WebDAV URL and API token,
55
REM then an "OpenCoperLock" entry (with the logo) appears in the right-click
66
REM "Send to" menu. Selected files upload to the "ComputerShared" space.

scripts/send-to/windows/install-windows.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<#
2-
OpenCoperLock install the right-click "send to OpenCoperLock" integration (Windows).
2+
OpenCoperLock - install the right-click "send to OpenCoperLock" integration (Windows).
33
44
Per-user, NO administrator rights needed. It:
55
1. installs the uploader (send.ps1), a windowless launcher (launch.vbs) and the brand icon into
66
%LOCALAPPDATA%\OpenCoperLock,
7-
2. asks for your WebDAV URL + API token (the token is DPAPI-encrypted for your Windows user
7+
2. asks for your WebDAV URL + API token (the token is DPAPI-encrypted for your Windows user -
88
unreadable by others, never leaves your machine) and your preferences,
99
3. pre-creates the "ComputerShared" space in your Drive,
1010
4. adds the integration points you chose:
11-
Explorer's "Send to > OpenCoperLock" (uploads ALL selected files in one go), and/or
12-
right-click "Drop on OpenCoperLock" / "Multi-Drop on OpenCoperLock" entries.
11+
- Explorer's "Send to > OpenCoperLock" (uploads ALL selected files in one go), and/or
12+
- right-click "Drop on OpenCoperLock" / "Multi-Drop on OpenCoperLock" entries.
1313
1414
Uploads land in the "ComputerShared" space. Everything runs hidden (no PowerShell window flash)
1515
and shows a small tray notification when done (can be turned off).

scripts/send-to/windows/launch.vbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
' OpenCoperLock windowless launcher.
1+
' OpenCoperLock - windowless launcher.
22
'
33
' Invoked by the "Send to", "Drop on OpenCoperLock" and "Multi-Drop on OpenCoperLock" entries with
44
' the selected file path(s) as arguments. It forwards them to send.ps1 and runs PowerShell HIDDEN

scripts/send-to/windows/send.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<#
2-
OpenCoperLock "Send to" uploader (Windows).
2+
OpenCoperLock - "Send to" uploader (Windows).
33
44
Invoked (via launch.vbs, hidden) with one or more file paths as arguments. Uploads each selected
55
file to the "ComputerShared" space (a top-level folder in your Drive) over WebDAV, shows a small
@@ -32,7 +32,7 @@ function Show-Toast($title, $text) {
3232

3333
Log "invoked with $($args.Count) arg(s): $($args -join ' | ')"
3434

35-
if (-not (Test-Path $cfgPath)) { Log 'no config'; Show-Toast 'OpenCoperLock' 'Not configured yet run the installer.'; exit 1 }
35+
if (-not (Test-Path $cfgPath)) { Log 'no config'; Show-Toast 'OpenCoperLock' 'Not configured yet - run the installer.'; exit 1 }
3636

3737
$cfg = Get-Content $cfgPath -Raw | ConvertFrom-Json
3838
$base = ($cfg.base).TrimEnd('/')
@@ -62,4 +62,4 @@ $tok = $null; $cred = $null
6262

6363
Log "done: ok=$ok fail=$fail"
6464
if ($fail -eq 0) { Show-Toast 'OpenCoperLock' "Sent $ok file(s) to ComputerShared." }
65-
else { Show-Toast 'OpenCoperLock' "Sent $ok, $fail failed see send.log." }
65+
else { Show-Toast 'OpenCoperLock' "Sent $ok, $fail failed - see send.log." }

scripts/windows-context-menu-manager.cmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
@echo off
22
REM ===========================================================================
3-
REM OpenCoperLock Windows right-click menu manager (elevated).
3+
REM OpenCoperLock - Windows right-click menu manager (elevated).
44
REM Double-click to tidy the Explorer right-click menu. Requests Administrator
5-
REM so it can also manage system-wide entries. Nothing is deleted items are
5+
REM so it can also manage system-wide entries. Nothing is deleted - items are
66
REM just disabled/enabled reversibly.
77
REM ===========================================================================
88
powershell -NoProfile -ExecutionPolicy Bypass -Command ^

scripts/windows-context-menu-manager.ps1

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<#
2-
OpenCoperLock Windows right-click menu manager.
2+
OpenCoperLock - Windows right-click menu manager.
33
44
A simple, SAFE, reversible tool to tidy the Explorer right-click menu that apps keep cluttering.
55
It lists two kinds of entries and lets you turn any of them on/off:
66
7-
Classic verbs (\shell\<verb>) disabled with a `LegacyDisable` flag.
8-
Shell-extension items (\shellex\ContextMenuHandlers) disabled via Windows' official
7+
- Classic verbs (...\shell\<verb>) - disabled with a `LegacyDisable` flag.
8+
- Shell-extension items (...\shellex\ContextMenuHandlers) - disabled via Windows' official
99
"Shell Extensions\Blocked" list.
1010
11-
NOTHING is deleted disabling just sets a flag, so you can re-enable anything later. Writing to
11+
NOTHING is deleted - disabling just sets a flag, so you can re-enable anything later. Writing to
1212
the system-wide (HKLM) entries needs Administrator; run the .cmd wrapper (it elevates) to manage
1313
everything. Per-user (HKCU) entries work without elevation.
1414
@@ -76,25 +76,26 @@ function Get-Entries {
7676

7777
function Toggle-Entry($e) {
7878
if ($e.Scope -eq 'HKLM' -and -not $IsAdmin) {
79-
Write-Host " ! '$($e.Name)' is system-wide (HKLM) re-run the .cmd as Administrator to change it." -ForegroundColor Yellow
79+
Write-Host " ! '$($e.Name)' is system-wide (HKLM) - re-run the .cmd as Administrator to change it." -ForegroundColor Yellow
8080
return
8181
}
8282
if ($e.Type -eq 'verb') {
8383
if ($e.Enabled) { New-ItemProperty -LiteralPath $e.Path -Name 'LegacyDisable' -Value '' -PropertyType String -Force | Out-Null }
8484
else { Remove-ItemProperty -LiteralPath $e.Path -Name 'LegacyDisable' -ErrorAction SilentlyContinue }
8585
} else {
86-
if ($e.Clsid -notmatch '^{.+}$') { Write-Host " ! '$($e.Name)' has no CLSID cannot toggle." -ForegroundColor Yellow; return }
86+
if ($e.Clsid -notmatch '^{.+}$') { Write-Host " ! '$($e.Name)' has no CLSID - cannot toggle." -ForegroundColor Yellow; return }
8787
if (-not $IsAdmin) { Write-Host " ! Shell-extension toggles need Administrator." -ForegroundColor Yellow; return }
8888
if (-not (Test-Path $BlockedKey)) { New-Item $BlockedKey -Force | Out-Null }
8989
if ($e.Enabled) { New-ItemProperty $BlockedKey -Name $e.Clsid -Value $e.Name -PropertyType String -Force | Out-Null }
9090
else { Remove-ItemProperty $BlockedKey -Name $e.Clsid -ErrorAction SilentlyContinue }
9191
}
92-
Write-Host (" {0} '{1}'" -f ($(if ($e.Enabled) { 'Disabled' } else { 'Enabled' }), $e.Name)) -ForegroundColor Green
92+
$action = if ($e.Enabled) { 'Disabled' } else { 'Enabled' }
93+
Write-Host (" {0} '{1}'" -f $action, $e.Name) -ForegroundColor Green
9394
}
9495

9596
# --- interactive loop ----------------------------------------------------------------------------
96-
Write-Host "OpenCoperLock right-click menu manager" -ForegroundColor Cyan
97-
if (-not $IsAdmin) { Write-Host "(not elevated system-wide entries are read-only; run the .cmd to elevate)" -ForegroundColor DarkGray }
97+
Write-Host "OpenCoperLock - right-click menu manager" -ForegroundColor Cyan
98+
if (-not $IsAdmin) { Write-Host "(not elevated - system-wide entries are read-only; run the .cmd to elevate)" -ForegroundColor DarkGray }
9899

99100
while ($true) {
100101
$entries = @(Get-Entries)

0 commit comments

Comments
 (0)