จะ 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 or008.remote systems.009. 010.Parameter List:011./S system Specifies the remote system to012.connect to. If omitted the system013.parameter defaults to the local014.system.015. 016./U username Specifies the user context under017.which the command should execute.018. 019./P password Specifies the password for the given020.user context.021. 022./RU username Specifies the user account (user023.context) under which the task runs.024.For the system account, valid values025.are "", "NT AUTHORITY\SYSTEM" or026."SYSTEM".027. 028./RP password Specifies the password for the user.029.To prompt for the password, the value030.must be either "*" or none.031.Password will not effect for the032.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 allow040.finer control over schedule041.recurrence. Valid values are listed042.in the "Modifiers" section below.043. 044./D days Specifies the day of the week to run045.the task. Valid values: MON, TUE,046.WED, THU, FRI, SAT, SUN and for047.MONTHLY schedules 1 - 31 (days of the048.month).049. 050./M months Specifies month(s) of the year.051.Defaults to the first day of the052.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 to057.wait before running a scheduled058.ONIDLE task.059.Valid range: 1 - 999 minutes.060. 061./TN taskname Specifies a name which uniquely062.identifies this scheduled task.063. 064./TR taskrun Specifies the path and file name of065.the program to be run by this066.scheduled task.067.Example: C:\windows\system32\calc.exe068. 069./ST starttime Specifies the time to run the task.070.The time format is HH:MM:SS (24 hour071.time) for example, 14:30:00 for072.2:30 PM.073. 074./SD startdate Specifies the first date on which the075.task runs. The format is076."mm/dd/yyyy".077. 078. 079. 080./ED enddate Specifies the last date when the task081.should run. The format is082."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, or098.FIRST, SECOND, THIRD, FOURTH, LAST, LASTDAY.099. 100.Examples:101.SCHTASKS /Create /S system /U user /P password /RU runasuser102./RP runaspassword /SC HOURLY /TN rtest1 /TR notepad103.SCHTASKS /Create /S system /U domain\user /P password /SC MINUTE104./MO 5 /TN rtest2 /TR calc.exe /ST 12:00:00105./SD 10/20/2001 /ED 10/20/2001 /RU runasuser /RP106. 107.SCHTASKS /Create /SC MONTHLY /MO first /D SUN /TN game108./TR c:\windows\system32\freecell109.SCHTASKS /Create /S system /U user /P password /RU runasuser110./RP runaspassword /SC WEEKLY /TN test1 /TR notepad.exe111.SCHTASKS /Create /S system /U domain\user /P password /SC MINUTE112./MO 5 /TN test2 /TR c:\windows\system32\notepad.exe113./ST 18:30:00 /RU runasuser /RP *114.SCHTASKS /Create /SC MONTHLY /MO first /D SUN /TN cell115./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 ความคิดเห็น:
แสดงความคิดเห็น