473,589 Members | 2,493 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 15392
"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************ ********@comcas t.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************ ********@comcas t.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
documentatio n 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************ ********@comcas t.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

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

Similar topics

4
14685
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...
5
4563
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, etc. All my command scripts utilizing this console application work fine when they are executed interactively. However, if they are executed via a scheduled task, they do not run. Or more precisely, the script seems to execute at the...
6
8230
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...
7
1715
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 below. If I run it manually then everything works fine. But the idea is that it runs overnight and.... If I set it up as a scheduled task (Win 2K server, running as a user that has full domain admin rights) then it works the first time, but...
1
1838
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). In the event a user runs the task manually I need to verify their identity for logging purposes. So I have two questions: 1. Is there a way to tell if a scheduled task was run because of its scheduled time or if a user manually initiated it?...
4
3692
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 command prompt but does nothing. Dim task As New System.Diagnostics.ProcessStartInfo("schtasks /create /tn ""Test2"" /tr C:\WINDOWS\system32\calc.exe /sc daily /st 15:14:00 /ru ""System""")
1
7481
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. We migrated a database from SQL 2000 to 2005 which is on a different box. I changed the connection in the vb script to use the new sql server. The original connection to SQL 2000 used the 'sa' account coded into the connection string , which...
1
4264
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 manually stop the task in order for the next scheduled backup to run. Is there a command line switch that I can use to force quit the program after it is completed or even if the job does not complete. Thanks for your help in advance
0
7929
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, 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...
0
7862
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,...
0
8357
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8223
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5729
isladogs
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...
0
5398
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();...
0
3847
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...
0
3887
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1196
bsmnconsultancy
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...

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.