NonProgrammer
NonProgrammer

Reputation: 1387

Run WinSCP script which is located in different folder than the winscp.com

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

Upvotes: 0

Views: 740

Answers (3)

Martin Prikryl
Martin Prikryl

Reputation: 202168

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

Upvotes: 1

gregbert
gregbert

Reputation: 446

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

Add directory to path

Upvotes: 1

Magoo
Magoo

Reputation: 79983

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

Upvotes: 1

Related Questions