Differences

This shows you the differences between the selected revisions of the page.

2016-03-07 2016-03-18
not using b: drive (martin) WINSCP_PATH/extension (martin)
Line 49: Line 49:
<code powershell> <code powershell>
Add-Type -Path (Join-Path $PSScriptRoot "WinSCPnet.dll") Add-Type -Path (Join-Path $PSScriptRoot "WinSCPnet.dll")
 +</code>
 +
 +If you are writing a script that you plan to use as a [[extension|WinSCP extension]] (a [[custom_command|custom command]]), you can use the copy of the assembly installed with WinSCP (//in the latest beta version only//). &beta In that case you can use the ''WINSCP_PATH'' environment variable to resolve the path to the assembly. To allow the script run even outside of WinSCP, you should fall back to the ''$PSScriptRoot'' approach (as above), if the variable is not defined:
 +
 +<code powershell>
 +$assemblyPath = if ($env:WINSCP_PATH) { $env:WINSCP_PATH } else { $PSScriptRoot }
 +Add-Type -Path (Join-Path $assemblyPath "WinSCPnet.dll")
</code> </code>

Last modified: by martin