使用批处理命令在Windows Scheduler中计划任务


0

我们如何使用批处理文件在Windows Scheduler中计划任务。我想使用批处理命令设置调度程序。

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%

1
欢迎来到超级用户!你试过什么了?你做了什么研究?:)
bertieb

我已经创建了一个批处理文件。现在使用该批处理文件,我想安排一个运行另一个批处理文件的任务。
Bhagyashree Sarkar

为什么需要批处理文件?
marijnr

需要在特定时间在Windows Server中执行pentaho。
Bhagyashree Sarkar

Windows具有内置的任务计划程序工具,您可以将其配置为在特定时间运行批处理文件。这样可以解决您的问题吗?
marijnr
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.