Run a Scheduled Task as a service?

Ok, it's a long story so I won't go into the details of why, but it must be done this way.

I need to force 60 W2K domain workstations (2K AD) to reboot at 19:00 every day. I need this to happen whether the machines are logged in or not, and their time is out of synch with the DC's by about 1 year all day (user accessing some training database from Oct 03) so I can't instigate this from a server, the command has to come from the local machine.

I can create a scheduled task to run reboot.bat as below:

shutdown.exe /C /L /R

That runs fine as a scheduled task when the machine is logged in but not when the machine has been logged off and is sitting at the Ctrl, Alt & Del screen.

My question is how can I get reboot.bat to run at 19:00 every day from the local workstation to force a reboot regardless of it's log in state?
LVL 6
youre1mAsked:
Who is Participating?
 
Debsyl99Connect With a Mentor Commented:
Hi
Or you can use AT. Just make sure that task scheduler service is running and is configured to logon as local service account - services - task scheduler-properties-log on which is general default anyway. Rename your bat file reboot.cmd, put it in say the root C: directory

at a command prompt paste this in:

AT 19:00 /EVERY:m,t,w,th,f,s,su cmd /c c:\reboot.cmd

hit return and it will reboot every day regardless of anyone logged in or not,

AT
http://www.ss64.com/nt/at.html

Deb :))


0
 
youre1mAuthor Commented:
I.e. Can I create a scheduled task to run as a service?
0
 
Yan_westCommented:
Use PShutdown from sysinternal, and create a batch file on one machine that shutdown all machine of your network remotly..!

http://www.sysinternals.com/ntw2k/freeware/psshutdown.shtml
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
youre1mAuthor Commented:
I can't do that, as I mentioned the system time varies from machine to machine so they can't talk to each other / servers, otherwise I would have done it. It has to run from the local machine.

Keep trying please!!
0
 
Yan_westCommented:
Not sure if this would work..

http://www.firedaemon.com/

FireDaemon is a utility that allows you to install and run virtually any native Win32 application or script (eg. BAT/CMD, Perl, Java, Python, TCL/TK) as a Windows NT, 2000, XP, 2003 & Longhorn service. FireDaemon features easy configuration (via GUI or XML), a low memory/CPU overhead, subprocess prioritisation, custom environments, CPU binding plus monitoring and logging to the event log and on-disk log files.
0
 
Danny ChildIT ManagerCommented:
also consider psExec
http://www.sysinternals.com/ntw2k/freeware/psexec.shtml
if you want to stick with shutdown.exe

I'm confused (obviously missing something) about the effect of the differing times.  Do all the machines have their own different local clocks, and you want them all to finish at 19:00 **local** time?  Are the clocks all over the place, or are they grouped ie some in PST, some in EST, and so on?

psshutdown works for me on servers, whether logged in or not as part of my UPS managment
psshutdown.exe -t 30 -f -c @%ServList% -m "System Shutting down" 2>&1 | findstr . >>"%LogFile%"

-t = time to shutdown in sec
-f = force apps to close
-c = allows user to abort
where %ServList% is a variable, containing the full path to a text file listing all machines.
-m = message to user
and the last bit is just some funkyness to parse the results to a log file variable, stripping out any blank lines.  

I'll keep playing with the Scheduled Tasks too...


0
 
oBdACommented:
This should run as well while nobody is logged on. Create a new account for this, with the necessary permissions to reboot the machine, and use this account to run the scheduled task with.
0
 
Danny ChildIT ManagerCommented:
one small thing, I'm fairly sure that the account that you run a scheduled task under CANNOT have a blank password.  just in case it's relevant!
0
 
youre1mAuthor Commented:
Ok, AT was thew way to go, although I had to change the system date back before applying the AT command as if I applied it using the current date and then changed the date back the AT command didn't apply, makes sense I guess but I thought with me telling it to run it every day it would not care about what date the command was applied on, for you info anyway, thanks all.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.