Как мы можем запланировать задачу в планировщике Windows, используя пакетный файл. Я хочу установить планировщик с помощью пакетной команды.
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%