Topic "Running Script without DOS Command Prompt"

Author Message
nssimpson
[View user's profile]

Joined: 2016-01-02
Posts: 3
Location: Manchester, UK
Hi Everyone

I've managed to get WinSCP to correctly download files via FTP on Windows 10 using a script ran from Command Prompt but just want to check something.

Originally I had this script:

open ftp://USER:PASS@ftp.WEBSITE.co.uk
get "data.zip" "Z:\Software\File.zip"
bye

I saved the script into a text file. I thought I could just run it by selecting Open With WinSCP.com. That didn't work and came up with Host "Drive Script is located on" does not exist (i.e. Host "C" does not exist).

I then saved a bat file with this inside:

"C:\Program Files (x86)\WinSCP\winscp.com" /script=C:\Users\msn\Desktop\Script.txt

When I run the .bat file it then works perfectly.

So my question is why does MSDos have to initiate the script rather than it being run directly?

Hope that makes sense.

Cheers

Nick
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24553
Location: Prague, Czechia
When you do "Open with winscp.com", the Windows runs "winscp.com C:\Users\msn\Desktop\Script.txt".

WinSCP tries to parse the C:\Users\msn\Desktop\Script.txt as a session URL according to its command-line syntax:
http://winscp.net/eng/docs/commandline

If you want to avoid the console window, use winscp.exe, not winscp.com
http://winscp.net/eng/docs/executables
nssimpson
[View user's profile]

Joined: 2016-01-02
Posts: 3
Location: Manchester, UK
Hi prikryl, thanks for your response.

I tried running the script using the WinSCP.exe but the same message pops up in its message window.

Kind regards

Nick
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24553
Location: Prague, Czechia
I've meant that if the problem with using winscp.com /script= is that it pops up a console window, you can use winscp.exe /script= to avoid that.

You cannot use "open with winscp.com" feature of Windows Explorer.

Though you can create a wrapper batch file, say winscp.bat that does:

Code:
"c:\program files (x86)\winscp\winscp.com" /script="%1"


and use "open with winscp.bat"
nssimpson
[View user's profile]

Joined: 2016-01-02
Posts: 3
Location: Manchester, UK
Thanks for the clarification. I have it working via a bat file that's run from the command prompt.

Kind regards
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License