0

Looking at example on WinSCP forums, I am able to put together a .bat file and associated .txt file, which works ONLY if both files are located under the same location as where WinSCP.com (and other WinSCP related files) is located:

C:\Program Files (x86)\WinSCP

Is there a way to run my .bat file successfully without having it under:

C:\Program Files (x86)\WinSCP

My .bat file content:

winscp.com /script=recon_SFTP.txt
pause

I did try moving my .bat file and .txt file to another location and adding location path, but it didn't work. I am guessing I need to escape spaces from my file path to location winscp.com?:

C:\Program Files (x86)\WinSCP\winscp.com /C:\Users\sqlservice\Desktop\SSmith1\script=recon_SFTP.txt
    pause
Martin Prikryl
  • 147,050
  • 42
  • 335
  • 704
NonProgrammer
  • 1,249
  • 1
  • 20
  • 41
  • 3
    `"C:\Program Files (x86)\WinSCP\winscp.com" /script="C:\Users\sqlservice\Desktop\SSmith1\recon_SFTP.txt"` – Squashman Nov 22 '16 at 16:05

3 Answers3

1

Enclose any string conaining spaces that you want to be treated as a single string in "double quotes"

Magoo
  • 68,705
  • 7
  • 55
  • 76
1

You could also add the WinSCP installation directory to your PATH. Then you can call winscp.com from any directory.

Add directory to path

Community
  • 1
  • 1
gregbert
  • 436
  • 2
  • 5
1

Just use a full path to the script file after the /script= switch.

And of course, you have to quote paths that contain spaces, like the path to the Program Files (x86).

"C:\Program Files (x86)\WinSCP\winscp.com" /script="C:\Users\sqlservice\Desktop\SSmith1\recon_SFTP.txt"

Though if the .txt is in the same directory as the .bat and you execute the .bat from its folder, you do not have to use a full path to the script:

"C:\Program Files (x86)\WinSCP\winscp.com" /script=recon_SFTP.txt
Martin Prikryl
  • 147,050
  • 42
  • 335
  • 704