473,748 Members | 10,649 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Enable / Disable scheduled task using vb.net

Does anyone know some code that will allow me to enable and/or disable a task
which already exists in the task scheduer. I have a task which runs at 15 min
intervals and from time to time I want to disable (and later enable) that
task. I'd like to do so programatically as part of another application
instead of opening the task scheduler and right clicking on the relevant task.

Any guidance or suggestions for code would be appreciated

Regards

Michael Bond
Nov 21 '05 #1
4 10768
In article <4D************ *************** *******@microso ft.com>, mabond wrote:
Does anyone know some code that will allow me to enable and/or disable a task
which already exists in the task scheduer. I have a task which runs at 15 min
intervals and from time to time I want to disable (and later enable) that
task. I'd like to do so programatically as part of another application
instead of opening the task scheduler and right clicking on the relevant task.

Any guidance or suggestions for code would be appreciated

Regards

Michael Bond


Michael...

You can grap a copy of my wrapper for the task scheduler...
http://www.mtogden.com/~tom/files/Sc...gAgent.NET.zip

--
Tom Shelton [MVP]
Nov 21 '05 #2
In article <4D************ *************** *******@microso ft.com>, mabond wrote:
Does anyone know some code that will allow me to enable and/or disable a task
which already exists in the task scheduer. I have a task which runs at 15 min
intervals and from time to time I want to disable (and later enable) that
task. I'd like to do so programatically as part of another application
instead of opening the task scheduler and right clicking on the relevant task.

Any guidance or suggestions for code would be appreciated

Regards

Michael Bond


I better give a little more explanation. If you grab the file, what you
get is a C# project. This project compiles to a .NET dll that wraps the
task scheduler's com interfaces. There are other similar libraries out
there as well... Any way, just include the project in your solution and
reference it from your vb projec and you should be able to do something
like:

Dim ts As New TaskScheduler
Dim tsk As Task = ts ("MyTask")

tsk.Disabled = true ' disable the task

ts.Dispose ()
HTH
--
Tom Shelton [MVP]
Nov 21 '05 #3
ok Tom

thanks for the help ... it's appreciated

Regards

Michael Bond

"Tom Shelton" wrote:
In article <4D************ *************** *******@microso ft.com>, mabond wrote:
Does anyone know some code that will allow me to enable and/or disable a task
which already exists in the task scheduer. I have a task which runs at 15 min
intervals and from time to time I want to disable (and later enable) that
task. I'd like to do so programatically as part of another application
instead of opening the task scheduler and right clicking on the relevant task.

Any guidance or suggestions for code would be appreciated

Regards

Michael Bond


I better give a little more explanation. If you grab the file, what you
get is a C# project. This project compiles to a .NET dll that wraps the
task scheduler's com interfaces. There are other similar libraries out
there as well... Any way, just include the project in your solution and
reference it from your vb projec and you should be able to do something
like:

Dim ts As New TaskScheduler
Dim tsk As Task = ts ("MyTask")

tsk.Disabled = true ' disable the task

ts.Dispose ()
HTH
--
Tom Shelton [MVP]

Nov 21 '05 #4
Tom

My Tech support staff have disabled C# on my .NET installation .... because
"they do not support it" ...... I cannot compile the project ..... and I
cannot convince my Tech support to enable C# (despite the fact they are not
being asked to support it) ...... any further suggestions

Michael

"Tom Shelton" wrote:
In article <4D************ *************** *******@microso ft.com>, mabond wrote:
Does anyone know some code that will allow me to enable and/or disable a task
which already exists in the task scheduer. I have a task which runs at 15 min
intervals and from time to time I want to disable (and later enable) that
task. I'd like to do so programatically as part of another application
instead of opening the task scheduler and right clicking on the relevant task.

Any guidance or suggestions for code would be appreciated

Regards

Michael Bond


I better give a little more explanation. If you grab the file, what you
get is a C# project. This project compiles to a .NET dll that wraps the
task scheduler's com interfaces. There are other similar libraries out
there as well... Any way, just include the project in your solution and
reference it from your vb projec and you should be able to do something
like:

Dim ts As New TaskScheduler
Dim tsk As Task = ts ("MyTask")

tsk.Disabled = true ' disable the task

ts.Dispose ()
HTH
--
Tom Shelton [MVP]

Nov 21 '05 #5

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

Similar topics

5
4577
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...
1
1994
by: stevenkblack | last post by:
I want to have a script that checks that my databases are up and running. I just want the scrip to connect to several databases and check the count of a certain table. I want this script to run every 10 minutes. I know that every night I am taking the database down for backup and they won't be available and the script will fail. I have been looking into the systools tables to see what changes when you make enable/disable a script but...
6
8250
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...
1
1844
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?...
1
7491
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...
0
1981
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...
3
3971
by: Donald A. Fisher | last post by:
Hello. I've been working a vb project and have a form with a button on it that performs some actions after disabling the button when clicked: Code disabling button and starting actions: Private Sub btnCreateExcel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreateExcel.Click Me.btnCreateExcel.Enabled = False Dim pCreateExcel As New ClassCreateExcel AddHandler pCreateExcel.CreateExcelCompleted, AddressOf...
0
1052
by: dhaval0011 | last post by:
How to Enable/Disable a task from task scheduler -------------------------------------------------------------------------------- Hi, Does anyone know some code that will allow me to enable and/or disable a task which already exists in the task scheduer. This topic has already been discussed in this forum, and also Mr. Tom Shelton provided the sollution. The link for the library and dll used in the project,...
9
3780
by: jdaelhousen | last post by:
I have a bit of a problem I'm hoping someone can shed some light on... I have a VB.Net console application written in VS 2003 that produces a .exe file that now sits on a Windows 2000 server directory. This exe does the following 3 things: 1.) Using the VB Interaction SaveSetting() method, it programmatically updates the system registry under the HKEY_CURRENT_USER\SOFTWARE key and saves a directory location used by a PDF driver (so that...
0
8991
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
8830
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
9541
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9370
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...
1
9321
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,...
0
8242
agi2029
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...
1
6796
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...
2
2782
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
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.