Home > Back-end >  Is there a way to reference a WinSCP script's directory to download files there?
Is there a way to reference a WinSCP script's directory to download files there?

Time:07-23

I have a pretty standard WinSCP SFTP script that grabs a few files and saves them to a SharePoint library. The script gets called from VBA so I cannot leave lcd blank. The location of the library is slightly different for different users so I need a way to get the script's location.

The script is stored in a synced SharePoint folder: %USERPROFILE%\User-Path\FTP\

For other users that path might be %USERPROFILE%\UserPath-FTP\FTP.

@echo off

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
 /command ^
    "open sftp://mysite.gov/ -hostkey=""ssh-rsa 4096 key#######=""" ^
    "cd /" ^
    "lcd ""           
  • Related