可能也有其他方法,比如用 WGet 等等,但是 推荐用 PowerShell ,为什么呢,因为 PowerShell 太强大呗
PowerShell 语法(demo1.ps1):
代码如下:
$date = Get-Date;
$beginTime = 2 * 60 ;
$endTime = 2 * 60 + 11;
$minuteCount = $date.hour * 60 + $date.minute
#if the time is right
if(($minuteCount -le $endTime ) -and ($minuteCount -ge $beginTime ))
{
#send request
$webClient = new-object System.Net.WebClient;
$webClient.Headers.Add("user-agent","PowerShell Script");
$webClient.Headers.Add("Referer","PowerShell Script");
$url = "//www.jb51.net/enAdmin/Handler/Listen_cms.ashx?code=listen_cms_20111130876";
$message = $webClient.DownloadString($url);
#write log
write("Message:"+$message);
}
else
{
write("Not Update");
}
sleep 5
Bat 语法(demo1.bat):
代码如下:
powershell %~sdp0Listen-Cms.ps1
sleep 5