简体   繁体   中英

Run a webpage from task scheduler and close it when the task finish using bat file

I created a bat file with the following code

"C:\Program Files\Internet Explorer\iexplore.exe" http://localhost:8083/

The bat file should run the link http://localhost:8083/ then I created a time scheduler on the server that run this bat file every 5 min so in theory the link should be called every 5 min

my problem is that the bat file is only being called once and I can't see that every 5 min a new instance of IE is called to run the webpage thus the code inside the weblink is not being executed every 5 min

what do you think i should do to fix this?

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

I think the problem is the task is never closed, so you need to change your bat file using another client to call your endpoint. For example, curl .

If you don't have curl follow this post

Here's an example that returns the server time:

ping.bat

@echo off
setlocal enabledelayedexpansion

(
  echo %date% %time%

  for /F %%x in ('curl http://localhost:3090/ping') do (
    echo %%~x
  )
)                                                                                                                               

Result:

C:\Users\Patricio>ping.bat
22/02/22 10:23:14,37
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    50  100    50    0     0     43      0  0:00:01  0:00:01 --:--:--    43
{"serverTime":"2022-02-22T10:23:15.5282576-03:00"}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM