How PowerShell regularly executes the. Net (C #) Program

Source: Internet
Author: User

There may also be other methods, such as WGet, but PowerShell is recommended. Why is PowerShell too powerful?

PowerShell syntax (demo1.ps1 ):

Copy codeThe Code is as follows: $ 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 = "http://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 syntax (demo1.bat ):Copy codeThe Code is as follows: powershell % ~ Sdp0Listen-Cms.ps1
Sleep 5

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.