Solved

Run a Scheduled Task as a service?

Posted on 2004-10-05
9
1,761 Views
Last Modified: 2008-01-09
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?
0
Comment
Question by:youre1m
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 6

Author Comment

by:youre1m
ID: 12226905
I.e. Can I create a scheduled task to run as a service?
0
 
LVL 15

Expert Comment

by:Yan_west
ID: 12226992
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
 
LVL 6

Author Comment

by:youre1m
ID: 12227071
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
 
LVL 15

Expert Comment

by:Yan_west
ID: 12227256
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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 23

Expert Comment

by:Danny Child
ID: 12227485
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
 
LVL 83

Expert Comment

by:oBdA
ID: 12228592
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
 
LVL 20

Accepted Solution

by:
Debsyl99 earned 500 total points
ID: 12229310
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
 
LVL 23

Expert Comment

by:Danny Child
ID: 12236401
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
 
LVL 6

Author Comment

by:youre1m
ID: 12481865
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

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now