Public Access
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
585befe922 | ||
|
|
0747612810 |
+45
-8
@@ -3,7 +3,6 @@
|
|||||||
# with it. Called by test-login.bat.
|
# with it. Called by test-login.bat.
|
||||||
|
|
||||||
$scriptRoot = Split-Path -Parent $PSCommandPath
|
$scriptRoot = Split-Path -Parent $PSCommandPath
|
||||||
$winscpDll = Join-Path $scriptRoot "WinSCP\WinSCPnet.dll"
|
|
||||||
|
|
||||||
function Read-Answer($question, $default) {
|
function Read-Answer($question, $default) {
|
||||||
while ($true) {
|
while ($true) {
|
||||||
@@ -31,18 +30,56 @@ Write-Host ("=" * 64) -ForegroundColor Cyan
|
|||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "Type the details exactly as they work in WinSCP or FileZilla." -ForegroundColor Gray
|
Write-Host "Type the details exactly as they work in WinSCP or FileZilla." -ForegroundColor Gray
|
||||||
|
|
||||||
if (-not (Test-Path $winscpDll)) {
|
# Find WinSCPnet.dll wherever it happens to live - this script is meant to be
|
||||||
Write-Host ""
|
# dropped next to whatever uploader is in use, not just this one.
|
||||||
Write-Host "WinSCPnet.dll not found at $winscpDll" -ForegroundColor Red
|
function Find-WinSCPDll {
|
||||||
Write-Host "Run setup.bat first, or copy this script next to the WinSCP folder." -ForegroundColor Yellow
|
$parent = Split-Path -Parent $scriptRoot
|
||||||
exit 1
|
$candidates = @(
|
||||||
|
(Join-Path $scriptRoot "WinSCP\WinSCPnet.dll"),
|
||||||
|
(Join-Path $scriptRoot "WinSCPnet.dll"),
|
||||||
|
(Join-Path $parent "WinSCP\WinSCPnet.dll"),
|
||||||
|
(Join-Path $parent "WinSCPnet.dll"),
|
||||||
|
"C:\Program Files (x86)\WinSCP\WinSCPnet.dll",
|
||||||
|
"C:\Program Files\WinSCP\WinSCPnet.dll"
|
||||||
|
)
|
||||||
|
foreach ($c in $candidates) {
|
||||||
|
if (Test-Path $c) { return $c }
|
||||||
|
}
|
||||||
|
# Anywhere under the folder this script sits in.
|
||||||
|
$found = Get-ChildItem -Path $scriptRoot -Filter "WinSCPnet.dll" -Recurse -File -ErrorAction SilentlyContinue |
|
||||||
|
Select-Object -First 1
|
||||||
|
if ($found) { return $found.FullName }
|
||||||
|
return $null
|
||||||
}
|
}
|
||||||
Get-ChildItem -Path (Join-Path $scriptRoot "WinSCP") -Recurse -File |
|
|
||||||
Unblock-File -ErrorAction SilentlyContinue
|
$winscpDll = Find-WinSCPDll
|
||||||
|
if (-not $winscpDll) {
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Could not find WinSCPnet.dll automatically." -ForegroundColor Yellow
|
||||||
|
Write-Host "It sits either in a WinSCP folder next to your upload script, or" -ForegroundColor Gray
|
||||||
|
Write-Host "in C:\Program Files (x86)\WinSCP\ if WinSCP is installed normally." -ForegroundColor Gray
|
||||||
|
Write-Host ""
|
||||||
|
$winscpDll = Read-Answer "Full path to WinSCPnet.dll" $null
|
||||||
|
if (-not (Test-Path $winscpDll)) {
|
||||||
|
Write-Host "Nothing at that path." -ForegroundColor Red
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Using $winscpDll" -ForegroundColor DarkGray
|
||||||
|
|
||||||
|
# Windows tags files copied from elsewhere as untrusted, which stops Add-Type
|
||||||
|
# loading them. Harmless everywhere else, so failure here is not worth a word.
|
||||||
|
try {
|
||||||
|
Get-ChildItem -Path (Split-Path -Parent $winscpDll) -Recurse -File -ErrorAction SilentlyContinue |
|
||||||
|
Unblock-File -ErrorAction SilentlyContinue
|
||||||
|
} catch { }
|
||||||
try {
|
try {
|
||||||
Add-Type -Path $winscpDll
|
Add-Type -Path $winscpDll
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host "Could not load WinSCPnet.dll - $($_.Exception.Message)" -ForegroundColor Red
|
Write-Host "Could not load WinSCPnet.dll - $($_.Exception.Message)" -ForegroundColor Red
|
||||||
|
Write-Host "If it says the operation is not supported, Windows has the file" -ForegroundColor Yellow
|
||||||
|
Write-Host "blocked: right-click it, Properties, tick Unblock, OK." -ForegroundColor Yellow
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
e384719 2026-08-30 per-practice logins + login test
|
0747612 2026-08-30 standalone login test
|
||||||
|
|||||||
Reference in New Issue
Block a user