Posted: 2016-02-15 08:36
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
"C:\WinSCP.com" /script=script.txt /log=log.txt
the script file contains
option batch continue
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)
"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"
Posted: 2016-02-15 08:59
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
So... I put a "Pause" at the start and end of the batch file, and then I got this gem
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
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
"C:\WinSCP.com" /script="C:\script.txt" /log="C:\log.txt"
You can post new topics in this forum
And it's free!