473,386 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

VB.NET Code for creating a scheduled task (.job)

Max
I'm writing a program that needs to be able to create custom .job files
and add them to the scheduled tasks folder. What I'd like to know is,
what is the format of a .job file and how do I go about adding in all
the data so that the task could run correctly?

If that is something not so easy to do, then say I need a certain part
of my program to execute on a schedule... How do I go about writing some
internal scheduling routine that won't utilize a lot of CPU power while
the program is running?

Thanks for any advice.
Nov 20 '05 #1
11 15366
"Max" <ma*****@yahoo.com> schrieb
I'm writing a program that needs to be able to create custom .job
files and add them to the scheduled tasks folder. What I'd like to
know is, what is the format of a .job file and how do I go about
adding in all the data so that the task could run correctly?

If that is something not so easy to do, then say I need a certain
part of my program to execute on a schedule... How do I go about
writing some internal scheduling routine that won't utilize a lot of
CPU power while the program is running?

Thanks for any advice.


I only found this one...

http://msdn.microsoft.com/library/en...start_page.asp

....but don't know how to implement it in VB.Net.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
In article <Rb********************@comcast.com>, Max wrote:
I'm writing a program that needs to be able to create custom .job files
and add them to the scheduled tasks folder. What I'd like to know is,
what is the format of a .job file and how do I go about adding in all
the data so that the task could run correctly?

If that is something not so easy to do, then say I need a certain part
of my program to execute on a schedule... How do I go about writing some
internal scheduling routine that won't utilize a lot of CPU power while
the program is running?

Thanks for any advice.


Go and get http://www.mtogden.com/~tom/files/Sc...gAgent.NET.zip.
This is a class library I wrote while I was initialy playing with C#.
This is callable from VB.NET. You just need to include the project in
your solution and reference it. You can look at the task scheduler
documentation on MSDN to get an idea about what each property does.
There may be a couple that aren't implemented - but since you have the
source...

--
Tom Shelton [MVP]
Nov 20 '05 #3
Max
Tom Shelton wrote:
In article <Rb********************@comcast.com>, Max wrote:

I'm writing a program that needs to be able to create custom .job files
and add them to the scheduled tasks folder. What I'd like to know is,
what is the format of a .job file and how do I go about adding in all
the data so that the task could run correctly?

If that is something not so easy to do, then say I need a certain part
of my program to execute on a schedule... How do I go about writing some
internal scheduling routine that won't utilize a lot of CPU power while
the program is running?

Thanks for any advice.


Go and get http://www.mtogden.com/~tom/files/Sc...gAgent.NET.zip.
This is a class library I wrote while I was initialy playing with C#.
This is callable from VB.NET. You just need to include the project in
your solution and reference it. You can look at the task scheduler
documentation on MSDN to get an idea about what each property does.
There may be a couple that aren't implemented - but since you have the
source...


Ok thanks for that, I'll have a look. However, just after taking a quick
look I can't figure out what you used to write those files. VS.NET
doesn't recognize any of those files and only opens them in text mode
(no syntax or anything else like that). Doesn't recognize
SchedulingAgent.csproj as a project file either. What do I do about this?
Nov 20 '05 #4
Max
Max wrote:
I'm writing a program that needs to be able to create custom .job
files and add them to the scheduled tasks folder. What I'd like to
know is, what is the format of a .job file and how do I go about
adding in all the data so that the task could run correctly?

If that is something not so easy to do, then say I need a certain part
of my program to execute on a schedule... How do I go about writing
some internal scheduling routine that won't utilize a lot of CPU power
while the program is running?

Thanks for any advice.

All right, this is proving to be far more complex then I need for it to
be and I don't really like the idea of the user being able to change the
schedule outside of the program. What I'm thinking right now, how would
it be possible to implement a simple scheduler myself? I'm going to have
a few tasks that the program needs to execute on a given schedule, for
every task I will determine the next time it needs to be run (date and
time), and after that all I need is some kind of a trigger when that
time comes. So how can I do this? Timers maybe, but I don't know how
good that will be for the CPU. This program will be running 24/7 in the
background, so unless it's running a task it needs to minimize resource
usage. Please let me know.
Nov 20 '05 #5
On 2004-04-30, Max <ma*****@yahoo.com> wrote:
Tom Shelton wrote:
In article <Rb********************@comcast.com>, Max wrote:

I'm writing a program that needs to be able to create custom .job files
and add them to the scheduled tasks folder. What I'd like to know is,
what is the format of a .job file and how do I go about adding in all
the data so that the task could run correctly?

<snip>



Ok thanks for that, I'll have a look. However, just after taking a quick
look I can't figure out what you used to write those files. VS.NET
doesn't recognize any of those files and only opens them in text mode
(no syntax or anything else like that). Doesn't recognize
SchedulingAgent.csproj as a project file either. What do I do about this?


Interesting... Those are my VS.NET 2003 project files. I simply
deleted the bin and obj directory and zipped it up. Are you using
VS.NET 2002? That's what I originally did the project in, but I have
long since converted it to 2003...

Anyway, if you have to - just create a new C# class library project, and
copy the files over and add them to the project.

--
Tom Shelton [MVP]
Powered By Gentoo Linux 1.4
One person's error is another person's data.
Nov 20 '05 #6
Max
Max wrote:
Max wrote:
I'm writing a program that needs to be able to create custom .job
files and add them to the scheduled tasks folder. What I'd like to
know is, what is the format of a .job file and how do I go about
adding in all the data so that the task could run correctly?

If that is something not so easy to do, then say I need a certain
part of my program to execute on a schedule... How do I go about
writing some internal scheduling routine that won't utilize a lot of
CPU power while the program is running?

Thanks for any advice.


All right, this is proving to be far more complex then I need for it
to be and I don't really like the idea of the user being able to
change the schedule outside of the program. What I'm thinking right
now, how would it be possible to implement a simple scheduler myself?
I'm going to have a few tasks that the program needs to execute on a
given schedule, for every task I will determine the next time it needs
to be run (date and time), and after that all I need is some kind of a
trigger when that time comes. So how can I do this? Timers maybe, but
I don't know how good that will be for the CPU. This program will be
running 24/7 in the background, so unless it's running a task it needs
to minimize resource usage. Please let me know.

Anyone???
Nov 20 '05 #7
Max
Max wrote:
Max wrote:
I'm writing a program that needs to be able to create custom .job
files and add them to the scheduled tasks folder. What I'd like to
know is, what is the format of a .job file and how do I go about
adding in all the data so that the task could run correctly?

If that is something not so easy to do, then say I need a certain
part of my program to execute on a schedule... How do I go about
writing some internal scheduling routine that won't utilize a lot of
CPU power while the program is running?

Thanks for any advice.


All right, this is proving to be far more complex then I need for it
to be and I don't really like the idea of the user being able to
change the schedule outside of the program. What I'm thinking right
now, how would it be possible to implement a simple scheduler myself?
I'm going to have a few tasks that the program needs to execute on a
given schedule, for every task I will determine the next time it needs
to be run (date and time), and after that all I need is some kind of a
trigger when that time comes. So how can I do this? Timers maybe, but
I don't know how good that will be for the CPU. This program will be
running 24/7 in the background, so unless it's running a task it needs
to minimize resource usage. Please let me know.

Anyone???
Nov 20 '05 #8
On 2004-05-01, Max <ma*****@yahoo.com> wrote:
Max wrote:
I'm writing a program that needs to be able to create custom .job
files and add them to the scheduled tasks folder. What I'd like to
know is, what is the format of a .job file and how do I go about
adding in all the data so that the task could run correctly?

If that is something not so easy to do, then say I need a certain part
of my program to execute on a schedule... How do I go about writing
some internal scheduling routine that won't utilize a lot of CPU power
while the program is running?

Thanks for any advice.

All right, this is proving to be far more complex then I need for it to
be and I don't really like the idea of the user being able to change the
schedule outside of the program. What I'm thinking right now, how would
it be possible to implement a simple scheduler myself? I'm going to have
a few tasks that the program needs to execute on a given schedule, for
every task I will determine the next time it needs to be run (date and
time), and after that all I need is some kind of a trigger when that
time comes. So how can I do this? Timers maybe, but I don't know how
good that will be for the CPU. This program will be running 24/7 in the
background, so unless it's running a task it needs to minimize resource
usage. Please let me know.


Max,

When you create a job using the task scheduler, set the Job's hidden
property to true. Then it won't show up in the task scheduler
interface. Do you need some sample code of actually using the library?

--
Tom Shelton [MVP]
Powered By Gentoo Linux 1.4
"`The best way to get a drink out of a Vogon is to stick
your finger down his throat...'"

- The Book, on one of the Vogon's social inadequacies.
Nov 20 '05 #9
Max
Tom Shelton wrote:
On 2004-05-01, Max <ma*****@yahoo.com> wrote:

Max wrote:
I'm writing a program that needs to be able to create custom .job
files and add them to the scheduled tasks folder. What I'd like to
know is, what is the format of a .job file and how do I go about
adding in all the data so that the task could run correctly?

If that is something not so easy to do, then say I need a certain part
of my program to execute on a schedule... How do I go about writing
some internal scheduling routine that won't utilize a lot of CPU power
while the program is running?

Thanks for any advice.

All right, this is proving to be far more complex then I need for it to
be and I don't really like the idea of the user being able to change the
schedule outside of the program. What I'm thinking right now, how would
it be possible to implement a simple scheduler myself? I'm going to have
a few tasks that the program needs to execute on a given schedule, for
every task I will determine the next time it needs to be run (date and
time), and after that all I need is some kind of a trigger when that
time comes. So how can I do this? Timers maybe, but I don't know how
good that will be for the CPU. This program will be running 24/7 in the
background, so unless it's running a task it needs to minimize resource
usage. Please let me know.


Max,

When you create a job using the task scheduler, set the Job's hidden
property to true. Then it won't show up in the task scheduler
interface. Do you need some sample code of actually using the library?


Well the reasons I decided not to use the scheduler are, first, that it
doesn’t provide me with the flexibility that I need. Sure I could just
come up with 20 different rules or whatever, but that just seems to be
an unnecessary complexity. Also, if I use the task scheduler then the
way I have to implement my program is that the user starts it up,
configures some tasks, then shuts the program down (after it added the
task to the scheduler), and then when the task is executed the program
has to start back up again. It can't be running 24/7 because when the
task is executed there is no way for the program to know that, the task
has to be the one that starts it. Since I do want the program to run
24/7 my own scheduler seems a better way to go. Not to mention that I
already have the code that goes through all the tasks and correctly
calculates the next task to be run, at what time, and at what date. Now
all I need is a routine that will wait for that time and date and run a
single function.

On the other hand, if you don't mind I would still like to see an
implementation of your library just in case I need it for the future.
Nov 20 '05 #10
On 2004-05-01, Max <ma*****@yahoo.com> wrote:
Max wrote:
I'm writing a program that needs to be able to create custom .job
files and add them to the scheduled tasks folder. What I'd like to
know is, what is the format of a .job file and how do I go about
adding in all the data so that the task could run correctly?

If that is something not so easy to do, then say I need a certain part
of my program to execute on a schedule... How do I go about writing
some internal scheduling routine that won't utilize a lot of CPU power
while the program is running?

Thanks for any advice.

All right, this is proving to be far more complex then I need for it to
be and I don't really like the idea of the user being able to change the
schedule outside of the program. What I'm thinking right now, how would
it be possible to implement a simple scheduler myself? I'm going to have
a few tasks that the program needs to execute on a given schedule, for
every task I will determine the next time it needs to be run (date and
time), and after that all I need is some kind of a trigger when that
time comes. So how can I do this? Timers maybe, but I don't know how
good that will be for the CPU. This program will be running 24/7 in the
background, so unless it's running a task it needs to minimize resource
usage. Please let me know.


Max,

When you create a job using the task scheduler, set the Job's hidden
property to true. Then it won't show up in the task scheduler
interface. Do you need some sample code of actually using the library?

--
Tom Shelton [MVP]
Powered By Gentoo Linux 1.4
"`The best way to get a drink out of a Vogon is to stick
your finger down his throat...'"

- The Book, on one of the Vogon's social inadequacies.
Nov 20 '05 #11
Max
Tom Shelton wrote:
On 2004-05-01, Max <ma*****@yahoo.com> wrote:

Max wrote:
I'm writing a program that needs to be able to create custom .job
files and add them to the scheduled tasks folder. What I'd like to
know is, what is the format of a .job file and how do I go about
adding in all the data so that the task could run correctly?

If that is something not so easy to do, then say I need a certain part
of my program to execute on a schedule... How do I go about writing
some internal scheduling routine that won't utilize a lot of CPU power
while the program is running?

Thanks for any advice.

All right, this is proving to be far more complex then I need for it to
be and I don't really like the idea of the user being able to change the
schedule outside of the program. What I'm thinking right now, how would
it be possible to implement a simple scheduler myself? I'm going to have
a few tasks that the program needs to execute on a given schedule, for
every task I will determine the next time it needs to be run (date and
time), and after that all I need is some kind of a trigger when that
time comes. So how can I do this? Timers maybe, but I don't know how
good that will be for the CPU. This program will be running 24/7 in the
background, so unless it's running a task it needs to minimize resource
usage. Please let me know.


Max,

When you create a job using the task scheduler, set the Job's hidden
property to true. Then it won't show up in the task scheduler
interface. Do you need some sample code of actually using the library?


Well the reasons I decided not to use the scheduler are, first, that it
doesn’t provide me with the flexibility that I need. Sure I could just
come up with 20 different rules or whatever, but that just seems to be
an unnecessary complexity. Also, if I use the task scheduler then the
way I have to implement my program is that the user starts it up,
configures some tasks, then shuts the program down (after it added the
task to the scheduler), and then when the task is executed the program
has to start back up again. It can't be running 24/7 because when the
task is executed there is no way for the program to know that, the task
has to be the one that starts it. Since I do want the program to run
24/7 my own scheduler seems a better way to go. Not to mention that I
already have the code that goes through all the tasks and correctly
calculates the next task to be run, at what time, and at what date. Now
all I need is a routine that will wait for that time and date and run a
single function.

On the other hand, if you don't mind I would still like to see an
implementation of your library just in case I need it for the future.
Nov 20 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
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...
5
by: A. Lovhaug | last post by:
I have a console application built in the .NET Framework. This application basically executes an XCopy based on parameters that I pass to it. I use it for creating scripts for backing up folders,...
6
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,...
7
by: Rob Oldfield | last post by:
I have a pretty straightforward app that's designed to take entries from a database and create a Word template containing AutoText entries using those entries. A basic outline of the code is...
1
by: satelite | last post by:
Hello, I am writing an exe that is intended to be run via a scheduled task. However, I also need the flexibility to have users run the scheduled task manually (right click task and select run). ...
4
by: Neil | last post by:
Hi, I am having problems in trying to create a scheduled task from within in application that carries out a health check on a client. I am using VS 2005. When the program runs it flashes a...
1
by: Myster Edd | last post by:
I have a strange problem that I think deals with security on SQL 2005. I have a scheduled task that runs on a Windows 2000 machine. It calls a vb script which creates a connection to SQL Server. ...
1
by: ranjitw | last post by:
I am running backup to .mdb file on a Windows 2003 server . My issue is that when the program completed it still is in a "running" state when I highlight the icon for the scheduled task I have to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.