OS: Windows Server 2008 R2
According to this web sites, https://stackoverflow.com/questions/5085116/windows-2008-server-task-scheduler-does-not-run-bat-batch-job,
there's a bug that prevent a batch file *with quotes inside* to be
executed
the link provides three possible solutions:
1.
create a launcher.bat (without quotes inside) that calls the proper
batch file
2. set the "Starting folder" in the parameters and remove the full path
in the "command"
3.
apply a patch http://support.microsoft.com/kb/951246 but is not
available any more
the task is executed as administrator, both manually (it works) and scheduled (it doesn't)
this is the batch file, that runs correctly when manually executed, as
I wrote above
note the quotes "" in the command for
rem ------------------------ start
D:
cd \TempBackup
@echo off
for /f "tokens=2 delims==" %%i in ('wmic path win32_localtime get
dayofweek /value') do set dow=%%i
xcopy \\192.168.42.54\as400\SV0%dow%\*.* d:\TempBackup\SV /c /f /h /y
/j
rem CURL
rem hidden parameters for privacy
SET FTP_URL=xxx.yyy.zzz.www
SET USERNAME=ftpuser
SET PASSWORD=********
SET REMOTE_DIR=/disk1/CompanyName/%dow%/
SET FOLDER_PATH=d:\TempBackup\SV
REM Iterate over each file in the folder and upload it using curl
FOR %%F IN ( %FOLDER_PATH%\*.* ) DO curl -T %%F ftp://%USERNAME%:%PASSWORD%@%FTP_URL%%REMOTE_DIR% --ftp-create-dirs
echo All files processed.
del /q %FOLDER_PATH%\*.*
rem ------------------------ end
any further help is appreciated
have a nice weekend
You misunderstood the problem. That problem has nothing to do with the problem in your batch file.
Your problem is an entirely different problem. But since you didn't mention how exactly, your batch file "doesn't work"
Here... if the file/folder enumerated by the `FOR` command contains a space or special character such as `&`, curl won't be executed as inteaded. To fix it, the `%%F` must be double-quoted. i.e.:
curl -T "%%F" ftp://%USERNAME%:%PASSWORD%@%FTP_URL%%REMOTE_DIR% --ftp-create-dirs
In Windows, when specifying a file system path, it should always be double-quoted if it's not already double-quoted. Especially if the path is unknown, or may vary, or can be anything.
at this point I'll search a third party tool to bypass the scheduler
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 65 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 13:55:30 |
| Calls: | 862 |
| Files: | 1,311 |
| D/L today: |
8 files (13,162K bytes) |
| Messages: | 265,525 |