จะ Add Task จากโปรแกรมที่เราสร้างขึ้นเองใส่ Windows Schedule Task ได้ไหมครับ
หมายถึงเพิ่มจากโปรแกรมเราสร้างเองเลยครับ ไม่ใช่ไปเพิ่มตรง Windows Schedule Task เองนะครับ
ลองวิธีนี้ครับ แบบง่ายๆ เลย (แบบยากหาไม่เจอ

ให้โปรแกรมเราเรียก command schtasks ของ Windows ครับ คือให้โปรแกรมเรารันคำสั่งภายนอกครับ
ส่วนนี่เป็นวิธีการใช้งานคำสั่ง schtasks ครับ สามาถเรียกดูได้จากการพิมพ์ที่ command prompt ว่า schtasks /? ครับ
** Help ตัวนี้ใช้ได้ักับ Windows XP ขึ้นไปนะครับ ของ 2000 อาจจะได้แต่น่าจะไม่เหมือนกัน
Command help
001.
SCHTASKS /Create [/S system [/U username [/P password]]]
002.
[/RU username [/RP password]] /SC schedule [/MO modifier] [/D day]
003.
[/I idletime] /TN taskname /TR taskrun [/ST starttime] [/M months]
004.
[/SD startdate] [/ED enddate]
005.
006.
Description:
007.
Enables an administrator to create scheduled tasks on a local or
008.
remote systems.
009.
010.
Parameter List:
011.
/S system Specifies the remote system to
012.
connect to.
If
omitted the system
013.
parameter defaults to the local
014.
system.
015.
016.
/U username Specifies the user context under
017.
which the command should execute.
018.
019.
/P password Specifies the password for the given
020.
user context.
021.
022.
/RU username Specifies the user account (user
023.
context) under which the task runs.
024.
For
the system account, valid values
025.
are
""
,
"NT AUTHORITY\SYSTEM"
or
026.
"SYSTEM"
.
027.
028.
/RP password Specifies the password for the user.
029.
To
prompt for the password, the value
030.
must be either
"*"
or none.
031.
Password will not effect for the
032.
system account.
033.
034.
/SC schedule Specifies the schedule frequency.
035.
Valid schedule types: MINUTE, HOURLY,
036.
DAILY, WEEKLY, MONTHLY, ONCE,
037.
ONSTART, ONLOGON, ONIDLE.
038.
039.
/MO modifier Refines the schedule type to allow
040.
finer control over schedule
041.
recurrence. Valid values are listed
042.
in the
"Modifiers"
section below.
043.
044.
/D days Specifies the day of the week to run
045.
the task. Valid values: MON, TUE,
046.
WED, THU, FRI, SAT, SUN and for
047.
MONTHLY schedules 1 - 31 (days of the
048.
month).
049.
050.
/M months Specifies month(s) of the year.
051.
Defaults to the first day of the
052.
month. Valid values: JAN, FEB, MAR,
053.
APR, MAY, JUN, JUL, AUG, SEP, OCT,
054.
NOV, DEC.
055.
056.
/I idletime Specifies the amount of idle time to
057.
wait before running a scheduled
058.
ONIDLE task.
059.
Valid range: 1 - 999 minutes.
060.
061.
/TN taskname Specifies a name which uniquely
062.
identifies this scheduled task.
063.
064.
/TR taskrun Specifies the path and file name of
065.
the program to be run by this
066.
scheduled task.
067.
Example: C:\windows\system32\calc.exe
068.
069.
/ST starttime Specifies the time to run the task.
070.
The time format is HH:MM:SS (24 hour
071.
time) for example, 14:30:00 for
072.
2:30 PM.
073.
074.
/SD startdate Specifies the first date on which the
075.
task runs. The format is
076.
"mm/dd/yyyy"
.
077.
078.
079.
080.
/ED enddate Specifies the last date when the task
081.
should run. The format is
082.
"mm/dd/yyyy"
.
083.
084.
085.
086.
/? Displays this help/usage.
087.
088.
Modifiers: Valid values for the /MO switch per schedule type:
089.
MINUTE: 1 - 1439 minutes.
090.
HOURLY: 1 - 23 hours.
091.
DAILY: 1 - 365 days.
092.
WEEKLY: weeks 1 - 52.
093.
ONCE: No modifiers.
094.
ONSTART: No modifiers.
095.
ONLOGON: No modifiers.
096.
ONIDLE: No modifiers.
097.
MONTHLY: 1 - 12, or
098.
FIRST, SECOND, THIRD, FOURTH, LAST, LASTDAY.
099.
100.
Examples:
101.
SCHTASKS /Create /S system /U user /P password /RU runasuser
102.
/RP runaspassword /SC HOURLY /TN rtest1 /TR notepad
103.
SCHTASKS /Create /S system /U domain\user /P password /SC MINUTE
104.
/MO 5 /TN rtest2 /TR calc.exe /ST 12:00:00
105.
/SD 10/20/2001 /ED 10/20/2001 /RU runasuser /RP
106.
107.
SCHTASKS /Create /SC MONTHLY /MO first /D SUN /TN game
108.
/TR c:\windows\system32\freecell
109.
SCHTASKS /Create /S system /U user /P password /RU runasuser
110.
/RP runaspassword /SC WEEKLY /TN test1 /TR notepad.exe
111.
SCHTASKS /Create /S system /U domain\user /P password /SC MINUTE
112.
/MO 5 /TN test2 /TR c:\windows\system32\notepad.exe
113.
/ST 18:30:00 /RU runasuser /RP *
114.
SCHTASKS /Create /SC MONTHLY /MO first /D SUN /TN cell
115.
/TR c:\windows\system32\freecell /RU runasuser
ตัวอย่าง
กรณีต้องการรัน ทุกวันอังคาร 8:00 เช้า ก็ให้โปรแกรมเราเรียกคำสั่งแบบนี้ครับ
1.
SCHTASKS /Create /S <i>computername</i> /SC WEEKLY /D TUE /RU <i>Username</i> /RP <i>password</i> /TN <i>OpenNotepad</i> /ST <i>08:00:00</i> /TR c:\windows\notepad.exe
กรณีต้องการรัน ทุกวัน 8:00 เช้า ก็ให้โปรแกรมเราเรียกคำสั่งแบบนี้ครับ
1.
SCHTASKS /Create /S <i>computername</i> /SC DAILY /RU <i>Username</i> /RP <i>password</i> /TN <i>OpenNotepad</i> /ST <i>08:00:00</i> /TR c:\windows\notepad.exe
0 ความคิดเห็น:
แสดงความคิดเห็น