Topic "can't use /script command line option when executing via VBA or task scheduler"

Author Message
thatginjadude
[View user's profile]

Joined: 2016-02-15
Posts: 2
I'm trying to execute a script to upload images onto a web server via VBA in access. I have a batch file that just has

Code:
"C:\WinSCP.com" /script=script.txt /log=log.txt


the script file contains

Code:
option batch continue
open ftp://images%40site.org.nz:password@ftp.site.org.nz/
mkdir temp
cd temp
put "image.png"
cd
rmdir live
mv temp live


this works fine if I doubleclick the batch file, alternately this works as well (whether using a windows shortcut or a batch file)

Code:
"C:\WinSCP.exe" /console /script=script.txt /log=log.txt


It's not a typo in my file path, as I can also get access and task scheduler to execute winscp either directly, or by running the above batch file IF I remove "/script=script.txt" from the command line, but the instant I put "/script=script.txt" back in it stops working. no error, no entry in the log file. just a quick flash of black as the command prompt window appears for a fraction of a second

this behaviour exhibits itself regardless of the contents or name of the script file. I've tried two different ftp servers and even empty script files. the behaviour is the same, fine when executed manually, and failure if executed via code or scheduler. in all cases of failure when run via vba or scheduler, I can get winscp to run by leaving everything the same and removing "/script=script.txt"

any thoughts?
thatginjadude
[View user's profile]

Joined: 2016-02-15
Posts: 2
after hours of messing around the answer manifested itself about 10 minutes after I sign up to a forum and make a post as is the way of things Razz

So... I put a "Pause" at the start and end of the batch file, and then I got this gem

Code:
Cannot open file "C:\Users\username\Documents\script.txt". The system cannot find the file specified


then ran the batch file from scheduler and got

Code:
Cannot open file "C:\WINDOWS\system32\script.txt". The system cannot find the file specified


so it seems that these applications are doing their own completely different things with relative paths.

changing my batch file to

Code:
"C:\WinSCP.com" /script="C:\script.txt" /log="C:\log.txt"


has worked
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