A small alarm clock that is based on a Windows scheduled task

Source: Internet
Author: User
Tags schtasks

Recently, the job is busy, it is inevitable to neglect his girlfriend. Then wrote a small program to remind her to sleep.

I wrote the original function with bat, with the following code:

@echo off
Title%date%%time:~,8%
Mshta vbscript:msgbox ("Yang Huachu! It's bedtime! ", 36," said the Master, "(Window.close)
Mshta vbscript:msgbox ("Yang Huachu! Take the pills! ", 36," said the Master, "(Window.close)

Mshta code that is used to invoke other languages in the batch process. Here I use it to invoke the MsgBox function in VBS to generate a popup dialog box.

This bat will pop up the cmd dialog when it runs, it's not friendly. I use a VBS program to invoke it:

Set Ws=wscript.createobject ("Wscript.Shell")
Ws.run "D: Intimate small alarm clock 1.0\ small alarm clock 1.0.bat/start", 0

Save it as a VBS file. The 0 here indicates a hidden window.

I need to have more features, for example, my girlfriend and I fell in love this July 13. I hope I can do a simple statistic.

I found that the bat was hard to implement, and VBS was easy to do:

Dim a
A=datevalue ("2014-7-13")
MsgBox "Dear change fish, now is" &now&+vbcrlf++vbcrlf+ "broken master has been with you" &datediff ("D", A,now) & "Days ~, continue to work Oh!" "," said the Broken master, "

The DateDiff function is used to return a time interval between two dates.

I hope that the small alarm clock can run at 23:00 per day, and the statistics program runs every time it is turned on. So I wrote a batch of this sort:

mkdir d:\ Small Alarm Clock 1.0
Copy "small Alarm clock 1.0.bat" "D: Intimate small alarm clock 1.0\ small alarm clock 1.0.bat"
Copy "VBS call. vbs" "D: Intimate small alarm clock 1.0\vbs call. vbs"
Copy "cute broken master. vbs" D: Intimate little alarm clock 1.0\ cute broken master. vbs "

SCHTASKS/CREATE/TN "Lovely Broken master"/tr d:\ thoughtful small alarm clock 1.0\ lovely broken master. Vbs/sc Onlogon
Schtasks/create/tn "Attentive small alarm Clock"/tr d:\ small Alarm clock 1.0\vbs call. VBS/SC daily/st 23:00:00/ed 2014/12/31

Pause

This bat's role is obvious. Once executed, it creates a new folder on the D drive and copies three of the subroutines. Then use Shctasks to create a new scheduled task that contracts the start time.

Onlogon is launched every time you log in. I try to use OnStart, the effect is unsatisfactory.

The SC daily/st 23:00:00/ed 2014/12/31 represents a 23:00 launch per day, and the plan lasts until 2014/12/31.

Such a warm little alarm clock is done.

A small alarm clock that is based on a Windows scheduled task

Related Article

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.