PDA

View Full Version : Any idea for using the Microsoft Task Scheduler


jackdaniels
12-10-2008, 09:02 AM
well I dont know how to use the Microsoft Task Scheduler from ams but there is a web site shows the way to it in other programming language...

http://www.codeproject.com/KB/shell/cscheduledtask.aspx

but I need help for that...

Thanks in advance

mwreyf1
12-10-2008, 09:44 AM
Do a search for SCHTASKS on this forum and you will find your answer.

There is a very long thread on doing just about everything from running to creating a scheduled task.

jackdaniels
12-10-2008, 10:33 AM
well i already tried it but it doesnt work...

File.Run("SCHTASKS", "\"/Create /SC weekly /D FRI /TN desrat /ST 12:47:00 /TR c:\\xfcgsg.exe\"", "", SW_MINIMIZE, false);

mwreyf1
12-10-2008, 03:33 PM
You need to tell the task who to run as. In the example below, it will run as "SYSTEM".

File.Run("SCHTASKS.EXE", "/Create /RU SYSTEM /SC WEEKLY /D FRI /TN desrat /ST 12:47:00 /TR c:\\xfcgsg.exe", "", SW_MINIMIZE, false);

jackdaniels
12-10-2008, 03:45 PM
thanks mwreyf1 but did u try that because it didnt work for me !!!

mwreyf1
12-11-2008, 08:56 AM
Yes it works for me on XP Pro SP3.

To confirm it is there, go ALL THE WAY into the "Scheduled Tasks" window (not just view from the Start Menu). You should now see the new task.

It will not show up in "Scheduled Tasks" when viewed from the Start Menu until you at least log off and back on.

Also keep in mind that if the app requires ANY user interaction then you can't run it as SYSTEM.


Hope this helps...

jackdaniels
12-11-2008, 12:41 PM
i give up... really it didnt work for me... i also looked at the task folder from windows folder but no....

mwreyf1
12-11-2008, 09:24 PM
Strange...

It works fine for me.

Try this:

Open a dos window (Start > Run and type cmd).

then

at the prompt type your command line:

SCHTASKS /Create /RU SYSTEM /SC WEEKLY /D FRI /TN desrat /ST 12:47:00 /TR c:\xfcgsg.exe

Now hit <enter>

Did that work?

If not, it should return an error explaining why it didn't work.

jackdaniels
12-12-2008, 05:26 AM
Strange...

It works fine for me.

Try this:

Open a dos window (Start > Run and type cmd).

then

at the prompt type your command line:

SCHTASKS /Create /RU SYSTEM /SC WEEKLY /D FRI /TN desrat /ST 12:47:00 /TR c:\xfcgsg.exe

Now hit <enter>

Did that work?

If not, it should return an error explaining why it didn't work.

it didnt work and it said that i have to command that way "SCHTASKS -?" !!!

longedge
12-12-2008, 06:30 AM
Just as a matter of interest I can't find/run SCHTASK.exe on my system.

I can run Task Scheduler but the Accessories/System Tools shortcut to it just contains a CLSID {D6277990-4C6A-11CF-8D87-00AA0060F5BF} which from my registry appears to call shell32.dll and mtask.dll.

I don't pretend to understand the way this works but certainly trying to run SCHTASK.exe either from a command line or the start/run option fails with a ......is not a recognised internal or external command or Windows can't find..... message.

That's on XP Home SP3.

holtgrewe
12-12-2008, 07:34 AM
I just tried it on a local machine here (mwreyf1 suggestion) and it worked fine - XP pro SP3.

jackdaniels
12-12-2008, 08:36 AM
i tried with the computer at the office and it didnt work either...

XP PRO SP3
and
XP Home SP2

mwreyf1
12-12-2008, 12:45 PM
It appears that SCHTASKS.EXE does not come with XP Home.

You could always include a copy of SCHTASKS.EXE (from XP PRO) in the docs folder of your app and then have the app drop it into the _SystemFolder.

Then create the task.


As for the office pc not working...maybe not an admin on the system??? Just a guess...