Programar uma tarefa no Windows Scheduler usando o comando batch

0

Como podemos agendar uma tarefa no agendador do Windows usando o arquivo em lotes. Eu quero definir um agendador usando o comando batch.

echo off
title Install Pentaho
set /p downloadPentaho=Dowload Pentaho [y/n]?: 
if %downloadPentaho%==y (call :download_pentaho) else (echo termenating program)
set /p downloadKtr=Dowload KTR files [y/n]?: 
if %downloadKtr%==y (call :download_ktr) else (echo termenating program) 
REM extract the ktr files and schedule pentaho in the windows server
set /p downloadBatch=Dowload Pentaho [y/n]?: 
EXIT /B 0

:download_pentaho
SET downloadUrl=http://example.com/pentaho/pentaho.zip
echo dowloading
powershell -Command "Invoke-WebRequest %downloadUrl% -OutFile pentaho.zip"
mkdir "C:\Users\Nilanjan Bose\bika_test\Pentaho\design-tools"
call :UnZipFile "C:\Users\Nilanjan Bose\bika_test\Pentaho\design-tools" "C:\Users\Nilanjan Bose\bika_test\pentaho.zip"
EXIT /B 0

:download_ktr
SET downloadUrl=http://example.com/pentaho/ktr.zip
echo dowloading
powershell -Command "Invoke-WebRequest %downloadUrl% -OutFile ktr.zip"
mkdir "C:\schedular"
call :UnZipFile "C:\schedular" "C:\Users\Nilanjan Bose\bika_test\ktr.zip"
EXIT /B 0

:UnZipFile <ExtractTo> <newzipfile>
set vbs="%temp%\_.vbs"
if exist %vbs% del /f /q %vbs%
>%vbs%  echo Set fso = CreateObject("Scripting.FileSystemObject")
>>%vbs% echo If NOT fso.FolderExists(%1) Then
>>%vbs% echo fso.CreateFolder(%1)
>>%vbs% echo End If
>>%vbs% echo set objShell = CreateObject("Shell.Application")
>>%vbs% echo set FilesInZip=objShell.NameSpace(%2).items
>>%vbs% echo objShell.NameSpace(%1).CopyHere(FilesInZip)
>>%vbs% echo Set fso = Nothing
>>%vbs% echo Set objShell = Nothing
cscript //nologo %vbs%
if exist %vbs% del /f /q %vbs%
    
por Bhagyashree Sarkar 14.06.2018 / 12:49

0 respostas