From 86bbe685c7396dcb457fbacf6a69c9d1e71ba39a Mon Sep 17 00:00:00 2001 From: Brad Lance Date: Sun, 5 Jul 2026 19:36:11 -0500 Subject: [PATCH] Fix WinSCPnet.dll load block and trailing-quote path bug in run.bat - Unblock-File the extracted WinSCP files after unzip: Windows tags downloaded files with Mark-of-the-Web, which makes Add-Type refuse to load WinSCPnet.dll (FileLoadException 0x80131515) until unblocked. - run.bat passed -EntityDir "%~dp0", but %~dp0 always ends in a trailing backslash. cmd's argument parser treats a lone backslash before a closing quote as an escaped literal quote rather than the string terminator, so PowerShell received the path with a stray " character baked in (Entities\CAMBS" instead of Entities\CAMBS), breaking Test-Path. Strip the trailing backslash before quoting it. --- Get-WinSCP.ps1 | 4 ++++ run.bat | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Get-WinSCP.ps1 b/Get-WinSCP.ps1 index 7fbd115..17cf5f9 100644 --- a/Get-WinSCP.ps1 +++ b/Get-WinSCP.ps1 @@ -50,5 +50,9 @@ try { exit 1 } +# Windows tags downloaded files as untrusted ("Mark of the Web"), which blocks +# Add-Type from loading WinSCPnet.dll later. Unblock everything we just extracted. +Get-ChildItem -Path $dest -Recurse -File | Unblock-File + Remove-Item $zip -Force Write-Host "WinSCP ready." -ForegroundColor Green diff --git a/run.bat b/run.bat index 79d64f5..8e17753 100644 --- a/run.bat +++ b/run.bat @@ -1,5 +1,7 @@ @echo off REM Place a copy of this file inside an Entity folder (e.g. Entities\CAMBS\) REM to run just that entity's upload. -powershell.exe -ExecutionPolicy Bypass -File "%~dp0..\..\engine.ps1" -EntityDir "%~dp0" +set "ENTITY_DIR=%~dp0" +set "ENTITY_DIR=%ENTITY_DIR:~0,-1%" +powershell.exe -ExecutionPolicy Bypass -File "%~dp0..\..\engine.ps1" -EntityDir "%ENTITY_DIR%" pause