We help IT Professionals succeed at work.

Starting scheduled job from command-line ?

tdemeyer
tdemeyer asked
on
260 Views
Last Modified: 2010-04-14
One of our servers has several jobs scheduled to run every x minutes, using a special user account.

Problem we face is that once in a while we need to start those jobs ahead of their planned time.

What happens now is somebody opens "Scheduled tasks", selects the task, right clicks, and select the "run"-option.

Can we do the same using the command line?
Comment
Watch Question

Commented:
'at' can schedule jobs from the command line, but you'd have to schedule it for 1 minute in the future or something.

Can't you just type in the command line that the task uses and hit enter?

Author

Commented:
Final goal is to put everything in a batch job, making it easier for the (novice) user to start thos sheduled jobs.

Problem with just entering from the command line is the fact that those scheduled jobs are not running in the logged-on user's context. "runas" cannot be used, as we don't want to give away that account's password ...

Commented:
Well, AT is the command-line version of the scheduler, so you could use AT to schedule the jobs for any point in time that you want. It doesn't run in the logged-on users' context, so the user won't need to know any passwords.

You could put all the tasks into a batch file and use AT to schedule that batch file. It would be really cool if you could grab the current time, and substitue current time + 5 mins (or whatever) into the AT command line....hmmm...

Author

Commented:
Ok,
But how can you enter the account's password (in non- human-readable format)?

Commented:
You don't enter passwords for the 'at' command...here's a page with the syntax:
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechnol/winxppro/proddocs/at.asp

Hmmm...it says you need to be a local admin to run 'at' - so this may not be ideal for you. I think the commands run in the context that the 'Task Scheduler' service is running in (probably 'Local System Account'). No one needs to be logged in at the time the scheduled jobs run...

Author

Commented:
That's right, we use AT quite often on our machines...

Problem is, when you create a scheduled job using the GUI, you must supply the user/password the job has to run in/under, but that's not possible with AT.
schTasks is another utility, but there again: password has to be provided in clear text...

Author

Commented:
Well,

solution was quite simple at the end:

schTask.exe can start a job, simply by entering the job's name  (as found in sheduled tasks) in the parameter list.



Author

Commented:
schtasks : one of the parameters enables you to start a named job, configured via sheduled tasks.

You simply use the name of the job in the parameter, and it fires up. No need to supplu usernames/passwords, as they are encoded in the task's jobfile.
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.