PDA

View Full Version : Scheduled Tasks



Desrat
05-02-2007, 09:27 PM
Anyone know how, or even if its possible to add a sheduled task using AMS??

wasim21k
05-03-2007, 08:55 AM
ask Scheduler options are stored in the registry in this location:

HKLM\SOFTWARE\Microsoft\SchedulingAgent\

here is example Create a daily task to run at 11 pm:

SCHTASKS /Create /SC weekly /D MON,TUE,WED,THU,FRI /TN MyDailyBackup /ST 23:00:00 /TR c:\backup.cmd /RU MyDomain\MyLogin /RP MyPassword

and you can check help just typing

SCHTASKS/?

all this is from command prompt but you can add it in ams you know your self how to do this.

Desrat
05-03-2007, 07:56 PM
if I type SCHTASKS/? into the command prompt I get

"SCHTASKS is not recognised as an internal or external command, operable program or batch file"

yosik
05-03-2007, 10:55 PM
You need to put a space before the /
schtasks /?

Yossi

wasim21k
05-04-2007, 03:12 AM
Desrat if you want i can give you example in ams to run some software on particular date time and day.
;)

Desrat
05-04-2007, 03:19 AM
that would be cool thx

wasim21k
05-04-2007, 05:30 AM
example to if you need any further help i can do this for you. ;)

Desrat
05-04-2007, 06:54 AM
I just dont think SCHTASKS works for me, I changed the code to this to test it

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

and it doesnt even add the task (checking from C:\Windows\Tasks folder)

Ive read and re-read all the info on microsoft (http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/schtasks.mspx?mfr=true) regarding SCHTASKS and none of it works for me, however the "at" (http://support.microsoft.com/kb/313565) method works but is useless in my case because the task runs hidden even when using the /interactive flag.

I'm completely clueless as to what to do next....I have noticed that SCHTASKS is available on my Server2003 machine so is it an XP home limitation?

EDIT. schtasks can be found in the windows\system32 dir on my server03 machine, but is not there on XP home...

TJ_Tigger
05-04-2007, 08:31 AM
you might have to quote your code like this and add another backslash for the one backslash to be recognized.

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

Tigg

Desrat
05-04-2007, 08:36 AM
thanks Tigg but the schtasks.exe doesnt even exist on my PC so I'm calling a non existant file anyway...

wasim21k
05-04-2007, 10:08 AM
sorry Desrat,
you are right one xp home there is no SCHTASKS command if i m not wrong you can use AT command and as far as my knowledge you can include SCHTASKS in your ams docs folder and run it from there and SCHTASKS can be found on Resource Kit (you can download it from ms web site for free). but if AT do for you or you can include both AT and SCHTASKS and before running any of them add script to check os and then run appropriate command.
TJ_Tigger you dont have to ad any extra \ or /.

Desrat
05-04-2007, 07:31 PM
ok well I put the schtasks.exe in my project and after some fiddling got a workable result, with one major drawback. If there is no password set for the current user account the task will not start. My idea was to get my app to do an auto update at the users discression and now im just gonna force an update check on preload, its much less complicated :)

Slcf
07-12-2007, 10:37 PM
first of all Sorry for my English I am French and I use a translator
Personally I use command AT with a XP Pro the command schtasks does not work for me. Here is an example

for 1 execution

File.Run("at", "05:22 c:\\test.exe", "", SW_SHOWNORMAL, false);


For week execution

File.Run("at", "05:22 /every:M,T,W,Th,F,S,Su c:\\test.exe", "", SW_SHOWNORMAL, false);


Visit For more instruction
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/at.mspx?mfr=true

JXBURNS
07-13-2007, 02:39 AM
You should be able to add the parameter /RU SYSTEM which will force the task to run as the SYSTEM account without a password.

You can always create the job manually (using the SYSTEM account) & then just copy the *.JOB files into C:\WINDOWS\TASKS. However it is random whether the job retains its RUN AS option as I have found out in the past so better to use the first option.

As you have worked out, Windows Home by default, does not normally allow you to add Scheduled Tasks via a command line. Bit like the fact NTBACKUP is not installed by default but can be from the CD.

Assume you have checked out: http://support.microsoft.com/default.aspx/kb/814596/

Rgds John