ali.rk
پنج شنبه 07 شهریور 1392, 23:51 عصر
سلام خوبید ؟
برای روشن کردن کامپیوتر ابتدا فایل taskschd.dll رو باید به Reference اضافه کنید .
C:\Windows\System32 مکان وجود taskschd.dll
109907
109908
یه دکمه هم بندازید.
حا لا نوبت کده (البته این کد کامل نیست ) :
Imports TaskScheduler
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim taskService As ITaskService = New TaskScheduler.TaskScheduler()
' Connect to the TaskService
taskService.Connect()
' Create a new task definition and assign properties
Dim taskDefinition As ITaskDefinition = taskService.NewTask(0)
taskDefinition.Settings.MultipleInstances = _TASK_INSTANCES_POLICY.TASK_INSTANCES_IGNORE_NEW
taskDefinition.RegistrationInfo.Description = "Testing the creation of a scheduled task via VB .NET"
taskDefinition.Principal.LogonType = _TASK_LOGON_TYPE.TASK_LOGON_S4U
taskDefinition.Settings.Hidden = False ' Set to True when running task should be hidden
' NOTE: When Hidden is true, it does not work if _TASK_LOGON_TYPE.TASK_LOGON_INTERACTIVE_TOKEN
' is used as parameter to RegisterTaskDefinition
'
'
' Add a trigger that will fire the task every other day
taskDefinition.Settings.WakeToRun = True
taskDefinition.Settings.Priority = 7
Dim taskTrigger As IDailyTrigger = _
DirectCast(taskDefinition.Triggers.Create _
(_TASK_TRIGGER_TYPE2.TASK_TRIGGER_DAILY), IDailyTrigger)
' Set to start ten minutes from now
taskTrigger.StartBoundary = _
DateTime.Now.AddMinutes(10).ToString _
("yyyy-MM-ddThh:mm:ss" & _
TimeZone.CurrentTimeZone.GetUtcOffset(Now).ToStrin g.Substring(0, 6))
' Rerun the task every other day
taskTrigger.DaysInterval = 2
' Create the Task action
Dim taskAction As IExecAction = _
DirectCast(taskDefinition.Actions.Create(_TASK_ACT ION_TYPE.TASK_ACTION_EXEC), IExecAction)
' The Path to the program
taskAction.Path = "C:\windows\notepad.exe"
' Set Arguments
taskAction.Arguments = ""
taskAction.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolde r.MyDocuments)
' Register the task in the Task Scheduler's root folder
Const taskName As String = "Testing creation of a scheduled task"
Dim rootFolder As ITaskFolder = taskService.GetFolder("\")
rootFolder.RegisterTaskDefinition( _
taskName, taskDefinition, _
CInt(_TASK_CREATION.TASK_CREATE_OR_UPDATE), _
"MyUsername", "MyPassword", _
_TASK_LOGON_TYPE.TASK_LOGON_INTERACTIVE_TOKEN_OR_P ASSWORD)
' Clean up the COM variables
While System.Runtime.InteropServices.Marshal.ReleaseComO bject(rootFolder) <> 0
Application.DoEvents()
End While
rootFolder = Nothing
While System.Runtime.InteropServices.Marshal.ReleaseComO bject(taskTrigger) <> 0
Application.DoEvents()
End While
taskTrigger = Nothing
While System.Runtime.InteropServices.Marshal.ReleaseComO bject(taskAction) <> 0
Application.DoEvents()
End While
taskAction = Nothing
While System.Runtime.InteropServices.Marshal.ReleaseComO bject(taskDefinition) <> 0
Application.DoEvents()
End While
taskDefinition = Nothing
While System.Runtime.InteropServices.Marshal.ReleaseComO bject(taskService) <> 0
Application.DoEvents()
End While
taskService = Nothing
GC.Collect() ' Start .NET CLR Garbage Collection
GC.WaitForPendingFinalizers() ' Wait for Garbage Collection to finish
End Sub
End Class
کد کامل می خواین : خودتون تلاش کنید :لبخند: (:خنده پسر عمه زایی:)
در این روش در واقع ما با ایجاد یک task توسط Task Scheduler کامپیوتر رو روشن می کنیم . آموزش ساخت task
http://www.howtogeek.com/119028/how-to-make-your-pc-wake-from-sleep-automatically/
کاهی اوقات این ارور رو میده
109909
که می تونید تیک do not store password رو بزنید :
109910
خب ساخت task تموم شد اما فایده :
به پوشه C:\Windows\System32\Tasks بروید . و task مورد نطر رو باز کنید . (با نوت پد)
109911
حالا اگر یه کم حوصله و هوشمندی به خرج بدید می تونبد کدتون رو کامل کنید .
کد شما باید با فایل (متن نوت پدمون) هماهنگ باشد تا درست کار کند
نکات :
در تمامی موارد درایو که ویندوز در آن نصب شده c می باشد.
اکثر کامپیوتر ها قابلیت روشن شدن از حالت خواب را دارن . ولی اگر یه تست درست کنید بهتر (مثلا اگر بعد از 5 دقیقه روشن شد یا نه رو از کاربر بپرسه. اگه گفت نه با عرض معذرت خواهی بگید کامپیوتر شما این قابلیت رو نداره )
مراجع :
http://www.codeproject.com/Tips/606876/How-to-create-a-task-in-Windows-Task-Scheduler
http://www.howtogeek.com/119028/how-to-make-your-pc-wake-from-sleep-automatically/
فایده task
یکی از فایده ها روشن کردن کامپیوتر است .
اگر یه کم هم کار کنید می تونید بفهمید که قابلیت انجام کار به صورت هر روز ساعت مثلا 2 رو داره دیگه احتیاج به timer گذاشتن نداره .
با تشکر از Andrew
(tnx Andrew)
لطفا ً یکی تو وینوز 8 در حالت shutdown هم امتحان کنه و نتیجه رو بگه . ممنون می شم
بخشید اگه کد رو کامل نکردم وقت نشد دیگه (مثلا دانش آموزما (ده هَ)).
یه تشکر هم بکنید ممنون می شم
ادمین جان واسه قانون شکنی ببخشید
برای روشن کردن کامپیوتر ابتدا فایل taskschd.dll رو باید به Reference اضافه کنید .
C:\Windows\System32 مکان وجود taskschd.dll
109907
109908
یه دکمه هم بندازید.
حا لا نوبت کده (البته این کد کامل نیست ) :
Imports TaskScheduler
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim taskService As ITaskService = New TaskScheduler.TaskScheduler()
' Connect to the TaskService
taskService.Connect()
' Create a new task definition and assign properties
Dim taskDefinition As ITaskDefinition = taskService.NewTask(0)
taskDefinition.Settings.MultipleInstances = _TASK_INSTANCES_POLICY.TASK_INSTANCES_IGNORE_NEW
taskDefinition.RegistrationInfo.Description = "Testing the creation of a scheduled task via VB .NET"
taskDefinition.Principal.LogonType = _TASK_LOGON_TYPE.TASK_LOGON_S4U
taskDefinition.Settings.Hidden = False ' Set to True when running task should be hidden
' NOTE: When Hidden is true, it does not work if _TASK_LOGON_TYPE.TASK_LOGON_INTERACTIVE_TOKEN
' is used as parameter to RegisterTaskDefinition
'
'
' Add a trigger that will fire the task every other day
taskDefinition.Settings.WakeToRun = True
taskDefinition.Settings.Priority = 7
Dim taskTrigger As IDailyTrigger = _
DirectCast(taskDefinition.Triggers.Create _
(_TASK_TRIGGER_TYPE2.TASK_TRIGGER_DAILY), IDailyTrigger)
' Set to start ten minutes from now
taskTrigger.StartBoundary = _
DateTime.Now.AddMinutes(10).ToString _
("yyyy-MM-ddThh:mm:ss" & _
TimeZone.CurrentTimeZone.GetUtcOffset(Now).ToStrin g.Substring(0, 6))
' Rerun the task every other day
taskTrigger.DaysInterval = 2
' Create the Task action
Dim taskAction As IExecAction = _
DirectCast(taskDefinition.Actions.Create(_TASK_ACT ION_TYPE.TASK_ACTION_EXEC), IExecAction)
' The Path to the program
taskAction.Path = "C:\windows\notepad.exe"
' Set Arguments
taskAction.Arguments = ""
taskAction.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolde r.MyDocuments)
' Register the task in the Task Scheduler's root folder
Const taskName As String = "Testing creation of a scheduled task"
Dim rootFolder As ITaskFolder = taskService.GetFolder("\")
rootFolder.RegisterTaskDefinition( _
taskName, taskDefinition, _
CInt(_TASK_CREATION.TASK_CREATE_OR_UPDATE), _
"MyUsername", "MyPassword", _
_TASK_LOGON_TYPE.TASK_LOGON_INTERACTIVE_TOKEN_OR_P ASSWORD)
' Clean up the COM variables
While System.Runtime.InteropServices.Marshal.ReleaseComO bject(rootFolder) <> 0
Application.DoEvents()
End While
rootFolder = Nothing
While System.Runtime.InteropServices.Marshal.ReleaseComO bject(taskTrigger) <> 0
Application.DoEvents()
End While
taskTrigger = Nothing
While System.Runtime.InteropServices.Marshal.ReleaseComO bject(taskAction) <> 0
Application.DoEvents()
End While
taskAction = Nothing
While System.Runtime.InteropServices.Marshal.ReleaseComO bject(taskDefinition) <> 0
Application.DoEvents()
End While
taskDefinition = Nothing
While System.Runtime.InteropServices.Marshal.ReleaseComO bject(taskService) <> 0
Application.DoEvents()
End While
taskService = Nothing
GC.Collect() ' Start .NET CLR Garbage Collection
GC.WaitForPendingFinalizers() ' Wait for Garbage Collection to finish
End Sub
End Class
کد کامل می خواین : خودتون تلاش کنید :لبخند: (:خنده پسر عمه زایی:)
در این روش در واقع ما با ایجاد یک task توسط Task Scheduler کامپیوتر رو روشن می کنیم . آموزش ساخت task
http://www.howtogeek.com/119028/how-to-make-your-pc-wake-from-sleep-automatically/
کاهی اوقات این ارور رو میده
109909
که می تونید تیک do not store password رو بزنید :
109910
خب ساخت task تموم شد اما فایده :
به پوشه C:\Windows\System32\Tasks بروید . و task مورد نطر رو باز کنید . (با نوت پد)
109911
حالا اگر یه کم حوصله و هوشمندی به خرج بدید می تونبد کدتون رو کامل کنید .
کد شما باید با فایل (متن نوت پدمون) هماهنگ باشد تا درست کار کند
نکات :
در تمامی موارد درایو که ویندوز در آن نصب شده c می باشد.
اکثر کامپیوتر ها قابلیت روشن شدن از حالت خواب را دارن . ولی اگر یه تست درست کنید بهتر (مثلا اگر بعد از 5 دقیقه روشن شد یا نه رو از کاربر بپرسه. اگه گفت نه با عرض معذرت خواهی بگید کامپیوتر شما این قابلیت رو نداره )
مراجع :
http://www.codeproject.com/Tips/606876/How-to-create-a-task-in-Windows-Task-Scheduler
http://www.howtogeek.com/119028/how-to-make-your-pc-wake-from-sleep-automatically/
فایده task
یکی از فایده ها روشن کردن کامپیوتر است .
اگر یه کم هم کار کنید می تونید بفهمید که قابلیت انجام کار به صورت هر روز ساعت مثلا 2 رو داره دیگه احتیاج به timer گذاشتن نداره .
با تشکر از Andrew
(tnx Andrew)
لطفا ً یکی تو وینوز 8 در حالت shutdown هم امتحان کنه و نتیجه رو بگه . ممنون می شم
بخشید اگه کد رو کامل نکردم وقت نشد دیگه (مثلا دانش آموزما (ده هَ)).
یه تشکر هم بکنید ممنون می شم
ادمین جان واسه قانون شکنی ببخشید