Unable to set local path for the Archive and Download command

Advertisement

ZianAtFirstWatch
Joined:
Posts:
7

Unable to set local path for the Archive and Download command

Steps to Reproduce:
1. Launch WinSCP from the Start menu.
2. Login to a SFTP host (we'll call it "F").
3. Right-click on a folder (e.g. public) and select File Custom Commands | Archive and Download...
4. Click OK
5. Watch a PowerShell window start up and successfully package all the files into a ZIP.

Actual Results (Final entries below; full log attached):
Archive archive.zip created.
Downloading...
Error: Exception calling "Check" with "0" argument(s): "Can't create file 'C:\Users\Zian\Documents\Personal\Webpage\archive.zip.filepart'.
System Error. Code: 3.
The system cannot find the path specified"

Press any key to exit...
Expected Result:
I would have expected WinSCP to let me specify the local path after step 3 or after step 5. I'm not surprised it can't create the file in c:\users\zian\documents\personal because there's no personal folder in the Documents folder on my computer's C drive.

https://winscp.net/eng/docs/faq_dir_default says that I can set the local path by going to Advanced Site Settings. However, that dialog says "Local directory is not used with Explorer interface."

Additional Details:
WinSCP Version: 5.19.2
Windows version: 21H1
Protocol: SFTP
GUI or automation: GUI

I've attached a ZIP file with screenshots, the session log, and the full PowerShell output.
Description: PowerShell window's contents
Description: Session log (replaced the host name with "F" and a few sensitive bits with the word "redacted")
Description: Screenshots

Reply with quote

Advertisement

ZianAtFirstWatch
Joined:
Posts:
7

I can't find the "Archive and Download..." menu item in the development build (11632 2021-07-27 - Do NOT distribute).

I confirmed that the menu item is still visible when I use version 5.19.2 (build 11614).

Has its location changed?

Description: Screenshot

Command Vanished.png

Reply with quote

ZianAtFirstWatch
Joined:
Posts:
7

Thanks for the suggestion. After doing that, I can start the command.

Then, PowerShell says:
Connecting...
Error: Exception calling "Open" with "1" argument(s): "The version of C:\Program Files (x86)\WinSCP\winscp.exe (6.0.0.0) does not match version of this assembly C:\Program Files (x86)\WinSCP\WinSCPnet.dll (5.19.2.0)."

Press any key to exit...

Reply with quote

Advertisement

ZianAtFirstWatch
Joined:
Posts:
7

Thanks for the new build. It's almost perfect.

The PowerShell window happily announces that all the files were added, the archive was created, and then it says "Downloading..."

A few seconds later, the window closes and I'm left wondering where archive.zip went.

I checked the setting I mentioned in the original post and it's still blank. I checked my Downloads and Documents folder and couldn't see the file there. Finally, in desperation, I checked the last folder I used when synchronizing a folder with the remote SFTP server. I saw the archive.zip there.

I don't think it's reasonable to ask users to memorize (for an indefinite amount of time) the full path of the last folder they used to synchronize with WinSCP.

Is there any chance that the program will let the user tell it where to put archive.zip?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,454
Location:
Prague, Czechia

I assume you are using the Explorer interface of WinSCP then. With the default two-pane Commander interface, the extension downloads the file to the directory opened in the local panel. In the Explorer interface, it downloads to the last local directory used. I might improve that if there's demand, but few users actually use the Explorer interface.
And this an easy fix, just edit the extension file as follows:
– replace -localPath "!\" with -localPath "%LocalPath%"
– add this after the @option ArchiveName line:
# @option       LocalPath -run textbox "&Target path:" "!\"
Let me know if it works.

Reply with quote

ZianAtFirstWatch
Joined:
Posts:
7

You're right. I'm using the Explorer-like view.

After making the 2 changes, I can see the new textbox in the dialog as shown in the screenshot. However, after PowerShell starts, the PowerShell window closest abruptly after a few minutes and no files are created in the destination directory (Downloads).

I've attached the command-line used to launch PowerShell. The information was recorded by Process Monitor.

Description: PowerShell window - initial view

PowerShell Screenshot.png

Description: Dialog screenshot

Archive and Download Dialog.png

Description: PowerShell command line

Reply with quote

Advertisement

ZianAtFirstWatch
Joined:
Posts:
7

WinSCPnet.dll is missing

Thanks for the tip. Based on the below output, is it possible that the PowerShell script that was installed as part of WinSCP 5.21.2 should be updated?

I re-applied your suggested tweaks after installing the update.

The computer said:
Microsoft Windows [Version 10.0.19043.1889]
(c) Microsoft Corporation. All rights reserved.

C:\Users\zchoy>powershell.exe -ExecutionPolicy Bypass -File "C:\Program Files (x86)\WinSCP\Extensions\ArchiveDownload.WinSCPextension.ps1" -sessionUrl "sftp://firstwatchcommunity:2s3yyMxu5CEkkGO;fingerprint=ssh-ed25519-k6RHsnipsnipsnipo94k;x-name=abc%2520Community%2520%28Marketing%2520Site%29@nice.try:15480/" -remotePath "/www/firstwatchcommunity_871/" -localPath "C:\Users\zchoy\Downloads" -archiveName "archive" -pause -sessionLogPath "" -path7zip "C:\Program Files\7-Zip\7z.exe" -archiveType zip -archiveCommand "" public
Error: Cannot bind parameter 'Path' to the target. Exception setting "Path": "Cannot find path 'C:\Program Files (x86)\WinSCP\Extensions\WinSCPnet.dll' because it does not exist."

Press any key to exit...

Screenshot of ArchiveDownload.WinSCPextension.ps1.png

Reply with quote

martin
Site Admin
martin avatar

Re: WinSCPnet.dll is missing

If you want to test the script, you need to either run it from a folder that also contains WinSCP.exe and WinSCPnet.dll, or set WINSCP_PATH environment variable to point to such folder (typically C:\Program Files (x86)\WinSCP).

Reply with quote

ZianAtFirstWatch

Thanks for the tip. I wasn't able to reproduce the crash I described in the 2022-07-01 16:55 post.

Would it be possible to add your tweak from the 2021-09-13 post to the script that is included in the WinSCP setup program?

Reply with quote

Advertisement

martin
Site Admin
martin avatar

ZianAtFirstWatch wrote:

Would it be possible to add your tweak from the 2021-09-13 post to the script that is included in the WinSCP setup program?
That won't work well with the default Commander interface.

Reply with quote

Advertisement

You can post new topics in this forum