Ammammata
2024-06-14 07:48:24 UTC
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
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
--
/-\ /\/\ /\/\ /-\ /\/\ /\/\ /-\ T /-\
-=- -=- -=- -=- -=- -=- -=- -=- - -=-
........... [ al lavoro ] ...........
/-\ /\/\ /\/\ /-\ /\/\ /\/\ /-\ T /-\
-=- -=- -=- -=- -=- -=- -=- -=- - -=-
........... [ al lavoro ] ...........