Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Scheduled Tasks


Reply
 
Thread Tools Display Modes
  #1  
Old 11-14-2005, 04:59 AM
dan_'s Avatar
dan_ dan_ is offline
Centurion
 
Join Date: Sep 2003
Location: Aussie Computer
Posts: 151
Question Scheduled Tasks


Does anyone know how I can change the "Scheduled Tasks" in Control Panel through code? Even how to shell it would help...

Thanks
Dan_
__________________
Digg.com member
Reply With Quote
  #2  
Old 11-14-2005, 05:22 AM
mcdonnc2004's Avatar
mcdonnc2004 mcdonnc2004 is offline
Junior Contributor
 
Join Date: Dec 2003
Location: Liverpool, UK
Posts: 276
Default

I found the following article helpful on this subject in the past:

http://www.codeproject.com/shell/Sch...TaskWizard.asp
Reply With Quote
  #3  
Old 11-14-2005, 05:25 AM
dan_'s Avatar
dan_ dan_ is offline
Centurion
 
Join Date: Sep 2003
Location: Aussie Computer
Posts: 151
Default

I want to be able to create a scheduled task through code, everything, date, time, program to run.

Dan_
__________________
Digg.com member
Reply With Quote
  #4  
Old 11-14-2005, 05:25 AM
George7a's Avatar
George7a George7a is offline
Saved by Grace
 
Join Date: Mar 2005
Location: Nazareth
Posts: 1,697
Default

Here's an example of scheduling a Task....

Code:
Option Explicit ' Schedule api's Declare Function NetScheduleJobAdd Lib "netapi32.dll" _ (ByVal Servername As String, Buffer As Any, Jobid As Long) As Long ' Schedule structure Type AT_INFO JobTime As Long DaysOfMonth As Long DaysOfWeek As Byte Flags As Byte dummy As Integer Command As String End Type ' Schedule constants Const JOB_RUN_PERIODICALLY = &H1 Const JOB_NONINTERACTIVE = &H10 Const NERR_Success = 0 Private Sub Command1_Click() Dim lngWin32apiResultCode As Long Dim strComputerName As String Dim lngJobID As Long Dim udtAtInfo As AT_INFO ' Convert the computer name to unicode strComputerName = StrConv(Text1.Text, vbUnicode) ' Setup the tasks parameters SetStructValue udtAtInfo ' Schedule the task lngWin32apiResultCode = NetScheduleJobAdd(strComputerName, udtAtInfo, lngJobID) ' Check if the task was scheduled If lngWin32apiResultCode = NERR_Success Then MsgBox "Task" & lngJobID & " has been scheduled." End If End Sub Private Sub SetStructValue(udtAtInfo As AT_INFO) Dim strTime As String Dim strDate() As String Dim vntWeek() As Variant Dim intCounter As Integer Dim intWeekCounter As Integer vntWeek = Array("M", "T", "W", "TH", "F", "S", "SU") With udtAtInfo ' Change the format of the time strTime = Format(Text2.Text, "hh:mm") ' Change the time to one used by the api .JobTime = (Hour(strTime) * 3600 + Minute(strTime) * 60) * 1000 ' Set the Date parameters If Val(Text3.Text) > 0 Then ' Set the task to run on specific days of the month i.e. 9th & 22nd of the month strDate = Split(Text3.Text, ",") For intCounter = 0 To UBound(strDate) .DaysOfMonth = .DaysOfMonth + 2 ^ (strDate(intCounter) - 1) Next Else ' Set the task to run on sepecific days of the week i.e. Monday & Thursday strDate = Split(Text3.Text, ",") For intCounter = 0 To UBound(strDate) For intWeekCounter = 0 To UBound(vntWeek) If UCase(strDate(intCounter)) = vntWeek(intWeekCounter) Then .DaysOfWeek = .DaysOfWeek + 2 ^ intWeekCounter Exit For End If Next Next End If ' Set the interactive property If Check1.Value = vbUnchecked Then .Flags = .Flags Or JOB_NONINTERACTIVE End If ' Set to run periodically If Option2.Value = True Then .Flags = .Flags Or JOB_RUN_PERIODICALLY End If ' Set the command to run .Command = StrConv(Text4.Text, vbUnicode) End With End Sub

also check the following link1

- George
Reply With Quote
  #5  
Old 11-14-2005, 05:27 AM
dan_'s Avatar
dan_ dan_ is offline
Centurion
 
Join Date: Sep 2003
Location: Aussie Computer
Posts: 151
Default

thanks
__________________
Digg.com member
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->