Hi,
Does anybody know how to get an application do something at a specific
time or date? I want to be able to choose when to back up some files,
for example once a month, once a week or every hour.
Thanks! 4 2129
I use a timer and in the tick event I check to see if it's time to do
whatever.
AxOn wrote:
Hi,
Does anybody know how to get an application do something at a specific
time or date? I want to be able to choose when to back up some files,
for example once a month, once a week or every hour.
Thanks!
On May 21, 8:27 am, AxOn <hannu_tahvanai ...@hotmail.com wrote:
Hi,
Does anybody know how to get an application do something at a specific
time or date? I want to be able to choose when to back up some files,
for example once a month, once a week or every hour.
Thanks!
Take a look at: http://msdn2.microsoft.com/en-us/library/aa394601.aspx
AxOn <ha************ ***@hotmail.com wrote in news:1179750430 .559255.323620
@36g2000prm.goo glegroups.com:
Hi,
Does anybody know how to get an application do something at a specific
time or date? I want to be able to choose when to back up some files,
for example once a month, once a week or every hour.
If your app is going to run infrequently and doesn't need to be aware of
state, I would use Windows Schedulerto handle scheduling: http://www.codeproject.com/csharp/tsnewlib.asp
Otherwise you can use the timer classes.
AxOn,
Here is some sample code I got awhile back which may help:
Create a class to hold the information about each job:
Public Class Job
Public Name As String
Public ScheduledDT As DateTime
Public Msg As String
End Class
Store instances of Job to represent each event in an ArrayList.
Then you pass this ArrayList to scheduleJobs() which will add each event to
a HashTable and create a Timer for it:
Code:
Public Class Form1
Inherits System.Windows. Forms.Form
Private Jobs As New Hashtable
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
' build some test jobs to be scheduled (you would build these from
your XML files)
Dim j As Job
Dim jal As New ArrayList
j = New Job
j.Name = "Event1"
j.Msg = "Wake up!"
j.ScheduledDT = DateTime.Now.Ad dSeconds(30)
jal.Add(j)
j = New Job
j.Name = "Event2"
j.Msg = "Reset Alarm Clock"
j.ScheduledDT = DateTime.Now.Ad dSeconds(31)
jal.Add(j)
j = New Job
j.Name = "Event3"
j.Msg = "Reset Alarm Clock Again"
j.ScheduledDT = DateTime.Now.Ad dSeconds(45)
jal.Add(j)
j = New Job
j.Name = "Event4"
j.Msg = "Crawl out of bed..."
j.ScheduledDT = DateTime.Now.Ad dSeconds(60)
jal.Add(j)
scheduleJobs(ja l)
End Sub
Private Sub scheduleJobs(By Val JobAL As ArrayList)
Dim j As Job
Dim t As System.Timers.T imer
Dim ms As Double
For Each j In JobAL
ms = j.ScheduledDT.S ubtract(DateTim e.Now()).TotalM illiseconds
If ms 0 Then ' if the event time has not yet passed...
t = New System.Timers.T imer(ms)
AddHandler t.Elapsed, AddressOf Me.t_Elapsed
Jobs.Add(t, j)
t.AutoReset = False ' fire it only once
t.Start()
End If
Next
Debug.WriteLine ("---------------------")
Debug.WriteLine (Jobs.Count & " Job(s) Scheduled")
End Sub
Private Sub t_Elapsed(ByVal sender As Object, ByVal e As
System.Timers.E lapsedEventArgs )
Dim t As System.Timers.T imer = CType(sender, System.Timers.T imer)
Dim j As Job = CType(Jobs.Item (t), Job)
' do something with the job
Debug.WriteLine ("---------------------")
Debug.WriteLine (j.Name)
Debug.WriteLine (j.ScheduledDT)
Debug.WriteLine (j.Msg)
' remove the job from the hashtable and destroy the timer
Jobs.Remove(t)
t.Dispose()
Debug.WriteLine ("---------------------")
Debug.WriteLine (Jobs.Count & " Job(s) Left")
End Sub
End Class
Hope this helps,
Steve This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bart Simpson |
last post by:
Hi,
I want to control 'Scheduled Tasks' in Windows 2003 by python program.
But I couldn't find any Python module about win32 'Scheduled Tasks'.
I could find only Perl module about it. (see http://taskscheduler.sourceforge.net)
But, I want to control 'Scheduled Tasks' by python :)
Is there any python module about win32 'Scheduled Tasks'?
|
by: Colin Steadman |
last post by:
We have a number of scheduled tasks on our IIS server that run daily at some point during the early morning. These tasks run as a specific user that has the correct permissions to perform whatever task (processing SQL so I'm told)
I have been asked if I can setup a page within ASP that a user could logon to with their own credentials (this I can do).
And once logged on be presented with a list of scheduled tasks which they can then...
|
by: John Bowman |
last post by:
Hi,
I have a C# app that needs to launch the "Add Scheduled Tasks" wizard found
in the control panel "Scheduled Tasks" applet. I realize that this "applet"
really just opens the tasks folder, but I need to launch the add tasks
wizard inside the folder. Does anyone have any ideas of how to do this? I
can't find anything in the MSDN regarding this. All it mentions is the Task
Scheduler API and I can't seem to find it in there either. Did...
|
by: Lenn |
last post by:
Hi,
I developed a console .exe application which is going to run on scheduled
basis, it will be scheduled to run in Windows Scheduled tasks. Client wants
some kind of utility that would help them manage scheduled tasks on different
servers. So, how can I add scheduled task to local machine or remote servers
programmatically?
Thanks.
|
by: kj7ny |
last post by:
How can I access and manipulate Scheduled Tasks in Windows using
Python?
I have a Windows XP workstation running Python 2.4.4 using the
win32all modules to control the windows services on multiple Windows
2003 servers. It works great.
However, I also need to remotely collect the settings for the
scheduled tasks (on those same Windows 2003 servers) and then
manipulate those task settings.
| |
by: kkkanoor |
last post by:
I am trying to schedule tasks in Windows from my C# program. The tasks get listed in Windows Schedule Tasks list, but it is not getting invoked. It seems I need to give the user name and password to start the task
OR
I have to set the property "RunOnlyIfLoggedOn" to true. But I don't know how to do this. Please help.
The following code I used is posted in one of the forums. Please find the code below.
--- CODE ---
simply use...
|
by: Paulson |
last post by:
Dear Freinds
I want to make a program that acts as a reminder for the
users.I need to open up the Scheduled task wizard programmatically.If you
type Tasks in the run command the Tasks folder(ie. Scheduled Taks folder)
is opened,but what I want is to open the Add Scheduled Task wizard in it.Is
there any run command to do that?
Also if I am able to open the Scheduled Task wizard like this is
there any way by which I can...
|
by: naveensrirangam |
last post by:
We want to do a total 10 number of scheduled tasks daily. These tasks will run in certain time in daily and every task application
developed in different technologies .
Now we are looking to do a automation system for all the daily scheduled processes.what is the best approach to check and run the
scheduled events / tasks.
|
by: BD |
last post by:
I'm running 8.2 on Windows.
I have a situation where several scheduled tasks were created in Task
Center, under an ID of a person who is leaving the organization.
This person's ID is to be deleted, but I see no way of reassigning the
owner of these tasks. And I can't change permissions on the tasks
without logging in as that 'owner' ID.
Is renaming the ID and resetting the password a viable option here?
|
by: thj |
last post by:
Hi,
Is it possible to start an scheduled task on a server from ASP.NET?
Thanks in advance.
Tommy.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |