如何使用批处理文件在 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%