Batch File works except when executed by scheduler

They have: 6 posts

Joined: Jul 2005

I wrote a batch file that will upload a log file to my ftp server, and when I manually run it, everything works fine. So I scheduled it using the AT command and it executes but doesn't work. If I use the /INTERACTIVE switch, I see the DOS window for it flash quickly on the screen, but I can't figure out a way to log the output of it. I tried to use the Scheduled Tasks thing in XP but it does the same thing. Any ideas on what the problem might be or how I can fix it?

Here's the file:

@echo off
setlocal

::Variables
set f=C:\ftpc.txt

::Compose ftp commands file
echo open SERVER-IP>>%f%
echo user USERNAME PASSWORD>>%f%
echo binary>>%f%
echo lcd "C:\Path To\Directory">>%f%
echo cd path-on-server>>%f%
echo put log.txt>>%f%
echo bye>>%f%

::Execute ftp command
::Use "-d" key for verbose output
ftp -n -d -s:%f% > C:\out.txt

::Cleanup
del /f /q %f%
endlocal
'

The file C:\out.txt never gets created when it's run as a scheduled event, but when I run manually, it's created and has the same output as the batch file (everything works fine). I can't figure out why it's not working... Confused

He has: 270 posts

Joined: Jan 2005

This may or may not work but it's an idea anyway...
1.create a shortcut icon for the program
2.right click on icon go to properties experiment with some compatibility options
with the shortcut dragged to the task scheduler not the batch file itself.

Hope it works

They have: 6 posts

Joined: Jul 2005

thanks for the response, but the task scheduler apparently doesn't get along with shortcuts because it says "Could not start" on the status column of the scheduler.

He has: 270 posts

Joined: Jan 2005

oh... bummer then well i have no more ideas

He has: 113 posts

Joined: Jul 2005

this might be a problem with paths.

do a search of your hdd for the filename u specify to see if its being created in the wrong place.

Your only using the relative cd switch instead of the absolute cd\

then again i dont know what your entering in the server path. if ur including the entire path it should be fine.

just an idea tho.

They have: 19 posts

Joined: May 2005

Check paths for proper format IE "c:\ Program Files\"

Also check to make sure you are using an account that has access to the files.

Also put some pauses in the batch job and see what it is failing at.

They have: 6 posts

Joined: Jul 2005

Well thanks for the help guys, I had already tried all those suggestions, but I moved the batch file to the root of the C drive instead of in the directory I wanted it in, and it worked. The directory it was in had an @ sign in the name....One of those weird quirks I should have known might cause a problem. Thanks folks.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.