473,378 Members | 1,417 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,378 software developers and data experts.

How to interface with Task Scheduler from VB???

Have an app and would like to allow easy addition of MYAPP.EXE /F /P (for
example)

my prog with command line args, as a job to be run.

Would like to make it easier on the user to run the app. I want to have it
run automatically as specified by the user.

What is the best thing to do and what platforms would it limit me to?

Should I just try to launch MMTask.exe? And maybe make a wizard to generate
the correct command line to copy and paste into the scheduler, or should I
make my own interface and add the task?

What suggestions do you have?

I have notice the servicecontroller for interacting with a task but after
connecting I don't know how you would interface with it and haven't seen
much docs.

Thanks,

shane
Nov 20 '05 #1
7 15169

"Shane Story" <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message
news:Oq**************@TK2MSFTNGP10.phx.gbl...
Have an app and would like to allow easy addition of MYAPP.EXE /F /P (for
example)

my prog with command line args, as a job to be run.

Would like to make it easier on the user to run the app. I want to have it run automatically as specified by the user.

What is the best thing to do and what platforms would it limit me to?

Should I just try to launch MMTask.exe? And maybe make a wizard to generate the correct command line to copy and paste into the scheduler, or should I
make my own interface and add the task?

What suggestions do you have?

I have notice the servicecontroller for interacting with a task but after
connecting I don't know how you would interface with it and haven't seen
much docs.

Thanks,

shane


I've succesfully used this class to schedule tasks.
http://www.codeproject.com/csharp/TSNewLib.asp

Look in the comments at the bottom of the page for winXP and remotely
scheduling info.

HTH
Slonocode

Nov 20 '05 #2
On 2003-12-21, Shane Story <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> wrote:
Have an app and would like to allow easy addition of MYAPP.EXE /F /P (for
example)

my prog with command line args, as a job to be run.

Would like to make it easier on the user to run the app. I want to have it
run automatically as specified by the user.

What is the best thing to do and what platforms would it limit me to?

Should I just try to launch MMTask.exe? And maybe make a wizard to generate
the correct command line to copy and paste into the scheduler, or should I
make my own interface and add the task?

What suggestions do you have?

I have notice the servicecontroller for interacting with a task but after
connecting I don't know how you would interface with it and haven't seen
much docs.

Thanks,

shane


The task scheduler works on all systems with IE4 up. It exposes itself
as a set of COM interfaces. You can access this through COM interop. I
have coded all the interop definitions a while ago in C#. Here is kind
of what your in for:

using System;
using System.Runtime.InteropServices;

namespace FireAnt.Util.SchedulingAgent
{
[Guid("148BD527-A2AB-11CE-B11F-00AA00530503"),
InterfaceType(ComInterfactType.InterfactIsIUnknown )]
internal interface ITaskScheduler
{
void SetTargetComputer
([MarshalAs(UnmanagedType.LPWStr)]string pwszComputer);

[return: MarshalAs(UnmanagedType.LPWStr)]
string GetTargetComputer();

IEnumWorkItems Enum();

[return: MarshalAs(UnmanagedType.IUnknown)]
object Activate(
[MarshalAs(UnmanagedType.LPWStr)]
string pwszName,
ref Guid riid);

// rest of the method declarations...
}

// the com coclass...
[ComImport, Guid("148BD52A-A2AB-11CE-B11F-00AA00530503")]
internal class CTaskScheduler
{
}
}
Then you can use them latter...

public static void Main()
{
// get a reference to the task scheduler interface..
ITaskScheduler taskScheduler = new CTaskScheduler();

Console.WriteLine(taskScheduler.GetTargetComputer( ));
}

Anyway, I can give you the interop defintions if you would like...
Sorry for the C# code - but that's what I wrote this stuff in. I
started to do it in VB.NET originally - but there was a bug in the
VB.NET compiler at the time that made impossilbe...
--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #3
Thanks Tom,

It would be great to have the definitions I would need and any advice on how
to ADD/LIST AND DELETE JOBS FROM TASK SCHEDULER

So the API you are telling me of should work the same for win98SP2, WINME,
WINXP, WIN2000, AND ABOVE? That is what I am shooting for and if necessary
win98 isn't a big deal I guess.

But my other real question is? Is it worth trying to tie into it or should
I just make a wizard that generates the commandline more easily and tell the
user to copy and pasted into a new task, by using the task scheduler? I am
trying to decide at present. This has to do with a simple backup software I
am making.

Please send the code you were speaking of. I will try to wrap in a Dll or
something. I don't know much c#, although I do know C and C++ to some
extent.

Thanks,

Shane

"Tom Shelton" <to*@mtogden.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
On 2003-12-21, Shane Story <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net>

wrote:
Have an app and would like to allow easy addition of MYAPP.EXE /F /P (for example)

my prog with command line args, as a job to be run.

Would like to make it easier on the user to run the app. I want to have it run automatically as specified by the user.

What is the best thing to do and what platforms would it limit me to?

Should I just try to launch MMTask.exe? And maybe make a wizard to generate the correct command line to copy and paste into the scheduler, or should I make my own interface and add the task?

What suggestions do you have?

I have notice the servicecontroller for interacting with a task but after connecting I don't know how you would interface with it and haven't seen
much docs.

Thanks,

shane


The task scheduler works on all systems with IE4 up. It exposes itself
as a set of COM interfaces. You can access this through COM interop. I
have coded all the interop definitions a while ago in C#. Here is kind
of what your in for:

using System;
using System.Runtime.InteropServices;

namespace FireAnt.Util.SchedulingAgent
{
[Guid("148BD527-A2AB-11CE-B11F-00AA00530503"),
InterfaceType(ComInterfactType.InterfactIsIUnknown )]
internal interface ITaskScheduler
{
void SetTargetComputer
([MarshalAs(UnmanagedType.LPWStr)]string pwszComputer);

[return: MarshalAs(UnmanagedType.LPWStr)]
string GetTargetComputer();

IEnumWorkItems Enum();

[return: MarshalAs(UnmanagedType.IUnknown)]
object Activate(
[MarshalAs(UnmanagedType.LPWStr)]
string pwszName,
ref Guid riid);

// rest of the method declarations...
}

// the com coclass...
[ComImport, Guid("148BD52A-A2AB-11CE-B11F-00AA00530503")]
internal class CTaskScheduler
{
}
}
Then you can use them latter...

public static void Main()
{
// get a reference to the task scheduler interface..
ITaskScheduler taskScheduler = new CTaskScheduler();

Console.WriteLine(taskScheduler.GetTargetComputer( ));
}

Anyway, I can give you the interop defintions if you would like...
Sorry for the C# code - but that's what I wrote this stuff in. I
started to do it in VB.NET originally - but there was a bug in the
VB.NET compiler at the time that made impossilbe...
--
Tom Shelton
MVP [Visual Basic]

Nov 20 '05 #4
Can I use this dll in a program that I am going to resell? --the task
scheduling wouldn't be the main functino of the program of course but a
perk.

Do I need to include a copyright or what? Couldn't find information on
that.

But this does look like a great solution.

I have just downloaded it and am checking it out.

THanks,

Shane

"Slonocode" <st*******************@yahoo.com> wrote in message
news:bs************@ID-137764.news.uni-berlin.de...

"Shane Story" <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message news:Oq**************@TK2MSFTNGP10.phx.gbl...
Have an app and would like to allow easy addition of MYAPP.EXE /F /P (for example)

my prog with command line args, as a job to be run.

Would like to make it easier on the user to run the app. I want to have

it
run automatically as specified by the user.

What is the best thing to do and what platforms would it limit me to?

Should I just try to launch MMTask.exe? And maybe make a wizard to

generate
the correct command line to copy and paste into the scheduler, or should I make my own interface and add the task?

What suggestions do you have?

I have notice the servicecontroller for interacting with a task but after connecting I don't know how you would interface with it and haven't seen
much docs.

Thanks,

shane


I've succesfully used this class to schedule tasks.
http://www.codeproject.com/csharp/TSNewLib.asp

Look in the comments at the bottom of the page for winXP and remotely
scheduling info.

HTH
Slonocode

Nov 20 '05 #5
"Shane Story" <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message
news:uL**************@TK2MSFTNGP12.phx.gbl...
Can I use this dll in a program that I am going to resell? --the task
scheduling wouldn't be the main functino of the program of course but a
perk.

Do I need to include a copyright or what? Couldn't find information on
that.

But this does look like a great solution.

I have just downloaded it and am checking it out.

THanks,

Shane

As far as I know everything on the site is freely useable.

Here is the faq page for the site.
http://www.codeproject.com/info/faq.asp
Just to be safe I'm sure you could email the author of the code.

Good Luck
Slonocode
Nov 20 '05 #6
Hey Tom,

Slonocode pointed me to a great library. Check it out. Works really good.

Thanks,

Shane

"Shane Story" <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message
news:uq**************@TK2MSFTNGP10.phx.gbl...
Thanks Tom,

It would be great to have the definitions I would need and any advice on how to ADD/LIST AND DELETE JOBS FROM TASK SCHEDULER

So the API you are telling me of should work the same for win98SP2, WINME,
WINXP, WIN2000, AND ABOVE? That is what I am shooting for and if necessary win98 isn't a big deal I guess.

But my other real question is? Is it worth trying to tie into it or should I just make a wizard that generates the commandline more easily and tell the user to copy and pasted into a new task, by using the task scheduler? I am trying to decide at present. This has to do with a simple backup software I am making.

Please send the code you were speaking of. I will try to wrap in a Dll or
something. I don't know much c#, although I do know C and C++ to some
extent.

Thanks,

Shane

"Tom Shelton" <to*@mtogden.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
On 2003-12-21, Shane Story <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> wrote:
Have an app and would like to allow easy addition of MYAPP.EXE /F /P (for example)

my prog with command line args, as a job to be run.

Would like to make it easier on the user to run the app. I want to have it
run automatically as specified by the user.

What is the best thing to do and what platforms would it limit me to?

Should I just try to launch MMTask.exe? And maybe make a wizard to generate the correct command line to copy and paste into the scheduler, or
should
I make my own interface and add the task?

What suggestions do you have?

I have notice the servicecontroller for interacting with a task but after connecting I don't know how you would interface with it and haven't

seen much docs.

Thanks,

shane


The task scheduler works on all systems with IE4 up. It exposes itself
as a set of COM interfaces. You can access this through COM interop. I
have coded all the interop definitions a while ago in C#. Here is kind
of what your in for:

using System;
using System.Runtime.InteropServices;

namespace FireAnt.Util.SchedulingAgent
{
[Guid("148BD527-A2AB-11CE-B11F-00AA00530503"),
InterfaceType(ComInterfactType.InterfactIsIUnknown )]
internal interface ITaskScheduler
{
void SetTargetComputer
([MarshalAs(UnmanagedType.LPWStr)]string pwszComputer);

[return: MarshalAs(UnmanagedType.LPWStr)]
string GetTargetComputer();

IEnumWorkItems Enum();

[return: MarshalAs(UnmanagedType.IUnknown)]
object Activate(
[MarshalAs(UnmanagedType.LPWStr)]
string pwszName,
ref Guid riid);

// rest of the method declarations...
}

// the com coclass...
[ComImport, Guid("148BD52A-A2AB-11CE-B11F-00AA00530503")]
internal class CTaskScheduler
{
}
}
Then you can use them latter...

public static void Main()
{
// get a reference to the task scheduler interface..
ITaskScheduler taskScheduler = new CTaskScheduler();

Console.WriteLine(taskScheduler.GetTargetComputer( ));
}

Anyway, I can give you the interop defintions if you would like...
Sorry for the C# code - but that's what I wrote this stuff in. I
started to do it in VB.NET originally - but there was a bug in the
VB.NET compiler at the time that made impossilbe...
--
Tom Shelton
MVP [Visual Basic]


Nov 20 '05 #7
"Shane Story" <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message
news:Om**************@TK2MSFTNGP09.phx.gbl...
Hey Tom,

Slonocode pointed me to a great library. Check it out. Works really
good.

Thanks,

Shane


Shane...

I'm glad you found something that works. I will check it out - but I have
long ago wrapped up these interfaces into my own library, so I'll probaby
stick with it for now :)

--
Tom Shelton
[MVP - Visual Basic]
Nov 20 '05 #8

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

Similar topics

1
by: Faiz | last post by:
We have developed an application in VB6 (say AA.exe). We wish to schedule the execution of this application (AA.exe) through Windows Task Scheduler. Is there a way through which we can add this...
3
by: Tim Marsden | last post by:
Hi I wish to write a task scheduler in my application. What is the best way to do this? Do I use the windows scheduler or try and write my own.? Is a timer checking every second feasible.? ...
4
by: Christina | last post by:
Dear All, How can I pop up the windows task scheduler inside of my .net application? Such as I have a button called Schedule Now, after clicking it, the Add Scheduled Task window will pop up,...
2
by: Kevin | last post by:
Hi, I am looking for a Task Scheduler with source code that has the following features: - Must perform all of the same functions as the Windows Task Scheduler - Must be able to run COM...
9
by: chandru.govind | last post by:
Hi, I built a C# application that scans a folder and pops up a form if there are any files present in the folder. I have scheduled this as a task to repeat every 1 min using the windows task...
3
by: mayur_hirpara | last post by:
Hi, I am writing a VB.NET application. It is a Windows application at the moment. The application contains a button. the click event of button perform a long running task. It needs to be started...
4
by: Sid Price | last post by:
Is there a .NET (2003) class available somewhere that might provide a comprehensive task scheduler with a better granularity than the one minute of the built-in scheduler on XP? Even down to 15...
0
by: =?Utf-8?B?U29tZW9uZSBlbHNl?= | last post by:
I'm attempting to open a program using Visual Basic 2005. Here's my code: Module Module1 Sub Main() Try AppActivate("The DownLoader") Catch Dim ReturnValue As Double = Shell("C:\Program...
1
by: Cupric | last post by:
I have a python script that runs fine from the command line or from within IDLE, but doesn't work through the Vista Task Scheduler. The script downloads some csv files and then uses pywin32 to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.