Sign in to follow this  
Followers 0
Qual-IT London

I am rather dim

7 posts in this topic

I did not realise creating a scheduled task would be so difficult. Nobody here has had an answer and there is nothing in the AutoIT docs about this.

2 days looking on the net didnt gather much either.

Calling the AT command is no good as the task is only created with the SYSTEM account - no network access :)

Making AT call a batch file and use RUNAS to start the task with different credentials results in Access Denied!

Using schtasks is only any use on xp/2003 or newer.....

So it's a dilema.

I finally found the solution with an old NT 4 resource kit file called JT.EXE

You can download it here. ftp://ftp.microsoft.com/reskit/win2000/jt.zip

Its a bitch to work out the command line syntax so i've done it for you.

In AutoIT

create your gui screen that asks for

time to run the task (i used two pull down menus one for hours one for mins)

days to run (i used 7 tick boxes for mon - fri)

username & password (two input boxes)

Then once you have gathered the info you want it looks like this

(for each checkbox say $monday=m, $tuesday=t etc)

$filename=yourjobname ; the name of the c:\windows\tasks\xxx.job file (without the .job extension)

$authu = username

$authp = password

$time = $list1 & ":" & $list2 (the two list boxes you populated with numbers for hours & mins)

$jtdays = $monday & $tuesday & $wednesday etc ; this gives jtdays the format "mtw"

then call this with jt.exe in your scriptdir

RunWait(@comspec & ' /c ' & 'jt.exe' & ' /saj ' & chr(34) & $filename & '.job' & chr(34) & ' /sc ' & $authu & ' ' & $authp & ' /ctj StartTime=' & $time & ' Type=Weekly TypeArguments=1,' & $jtdays & ' Disabled=0' & ' /sj ApplicationName=' & chr(34) & @scriptdir & '\yourscript.exe' & chr(34) & ' WorkingDirectory=' & chr(34) & @scriptdir & chr(34), @scriptdir, @SW_HIDE )

you can like I did add your own error detection routines around this.

job done (i hope)

Now if I could only work out the command for JT to run the scheduled task with the "Wake computer" option ticked :mellow:

Share this post


Link to post
Share on other sites



Hi,

seems to be there is someone quite happy getting it work after all. :)

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

I've used AT and SCHTASKS extensively. Both have their limits (AT is very limited, and SCHTASKS cannot create multi-schedule events) so when I cannot create a task using one of those tools, I just create the task file directly.

Tasks are .job files in C:\Windows\Tasks. Create a few tasks, study the .job files to learn the format, and then you can create your own tasks. QED

Share this post


Link to post
Share on other sites

I've used AT and SCHTASKS extensively. Both have their limits (AT is very limited, and SCHTASKS cannot create multi-schedule events) so when I cannot create a task using one of those tools, I just create the task file directly.

Tasks are .job files in C:\Windows\Tasks. Create a few tasks, study the .job files to learn the format, and then you can create your own tasks. QED

Really??

If I open a job file I get..

Û

€5ÔwÄA¥ñQ˜`°GüF ˜ <

s €! c : \ b a c k u p . c m d c :

C h r i s L a m b e r t 0 Ö >

Share this post


Link to post
Share on other sites

Really??

If I open a job file I get..

Û

5ÔwÄA¥ñQ`°GüF <

s ! c : \ b a c k u p . c m d c :

C h r i s L a m b e r t 0 Ö >

Yes, it's a binary file - you can't really get anything useful out of it if you display it as ASCII.

What I meant was create a scheduled task (using the GUI, if that's easier for you). Now make a copy of that job, like call it task2.job if the first one is task1.job. Now go in and make some small change to the task (like change the scheduled time by 1 minute) and save it. Now use a file comparison utility to campare the 2 files. Where ever the difference is, then you know that's where it stores that information (the scheduled minute, in this case). Keep doing that and pretty soon you'll have the whole job file figured out. Use that knowledge to create a job file on your own (from scratch) or the easier way (the way I do it) is create a basic task with SCHTASKS, then edit the file to make the changes that you couldn't do through SCHTASKS.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Calling the AT command is no good as the task is only created with the SYSTEM account - no network access :)

Making AT call a batch file and use RUNAS to start the task with different credentials results in Access Denied!

Using schtasks is only any use on xp/2003 or newer.....

So it's a dilema.

I finally found the solution with an old NT 4 resource kit file called JT.EXE

Is there a way to schedule a task running as user without having to input password?

From microsoft.com:

Tasks run with with permissions of the NT Authority\System account do not require a password and SchTasks.exe does not prompt for one.

So I assume that using SchTasks.exe I can only run a task as system. Right?

From tj.exe help:

The password may also specified as NULL if the account name is set.

NULL as a password indicates that the task should be run ONLY if

the specified user is logged on at the time the task is set to

execute. Users may create tasks of this type only for themselves.

Administrators may create them for any user.

It gave me a wish, but

"/sc @UserName NULL" command doesn't make start task at all even if I launch task from same account I used to create task. I really can't understand what "if the account name is set" means :D

Edited by masvil

Share this post


Link to post
Share on other sites

Is it possible to use jt.exe to run a task with parameters?

Like:

"C:\mytask.exe" /P

I couldn't figure out a way to do it.

BTW... with JT.exe can gui based tasks work as well even if the user is not logged in? Or Tasks that use autoit to click on certain gui buttons?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0