Link to home
Start Free TrialLog in
Avatar of Jeff swicegood
Jeff swicegood

asked on

Sheduled daily reboot in WIndows 7 only runs once

Hi,

I am trying to shedule a daily reboot on a WIndows 7 64bit machine.

I have setup my task in task manager. The PC reboots at the scheluled time the first time only, and then never reboots again. There is no message I can see about the task failing.

I created a file called reboot.bat  tha contians "shutdown /r" and then set it to run daily. When I run it manually through task manager it runs.

I have tried running taksmanager for setting up the task as both administrator and regular user. Seems to make no difference.
Avatar of 10023
10023

Just a thought...is your system clock accurate??
Avatar of Sumesh BNR
Have you selected 'One time only' when creating this task?
check the run if logged on  option too (have you checked)
Avatar of Jeff swicegood

ASKER

Yes, my trigger page looks exactly like the picture.
System Clock is Right
Run only when user logged on is checked
After the task executes and the computer reboots, the Next Run TIme field is blank.
Is there a particular reason you created a batch file to perform the reboot command instead of just specifying the shutdown.exe command in the Actions tab?

In the Actions tab of your task, remove the existing entry for the batch file then click on New > select Start a program from the Action drop down > in the Program/script box type in shutdown.exe > in the Add arguments (optional) field type in -rOK > test the task again.
I tried it both ways. Same thing happens.

More info: When I first start the task sheduler I get the error: "Selected Task "(0)" not longer exists. To see the current task click Refresh".

When I hit refresh the errror pops up again.

Also when I click "Display all running tasks" I ger the error "Catastrophic Failure (Exception from HRESULT 0x8000FFFF (E_UNEXPECTED)
Jeff, simply take the account "system" as executioner and all will be good.

My guess about the "why is this happening" (just a guess): you are on a domain. The default domain policy sets who has the privilege to run as a batch job (that is a user privilege required for scheduled tasks!). Whenever you setup that task, the account you chose was granted that privilege but after a reboot, a policy refresh occurs and overwrites that setting, rendering the task broken. Have seen that "problem" millions of times.

If that's not it, please look at the history tab of that task, that's like a log file.
SOLUTION
Avatar of VB ITS
VB ITS
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Surprisingly, setting system as the executor did not work. Here are the tests I have run.

PS C:\Windows\system32> sfc /scannow

Beginning system scan.  This process will take some time.

Beginning verification phase of system scan.
Verification 100% complete.

Windows Resource Protection did not find any integrity violations.

Open in new window


Output of tasks query
schtasks-query.txt

I did not run chkdsk yet, as I only have remote access late a night.

I did insert another task with your command line.
Reboot                                   11/30/2014 2:03:02 PM  Ready
Reboot test                              Disabled



So we will know at 2PM tomorrow  (30 Nov)
Some notes: your output file talks about insufficient access permissions - you did not execute it elevated, right? run cmd.exe elevated and un it again.
->sfc and checkdisk would not repair tasks. Task corruption as indicated by "catastrophic failure" can be undone by locating corrupt tasks, deleting their files and registry entries and recreating them.

Then: what about the history tab I mentioned, what does it say?
Folder: \MyTasks
TaskName                                 Next Run Time          Status
======================================== ====================== ===============
Reboot                                   11/30/2014 2:03:02 PM  Ready
Reboot test                              Disabled

Which one of these two tasks is the one that is failing and is one of these the one you added with SCHTASKS?
Yes I did run it with elevated privledges. Just to be sure I ran the query again as admin and the output is the same, with the messages about not having the access level.

@lionelmm Here are the pertinent part of the the updated schtasks query after adding your new task with SHCTASKS.

I forgot to change the task name so it remained "Name of Your Task"

Folder: \
TaskName                                 Next Run Time          Status
======================================== ====================== ===============
Name of your Task                 N/A                             Ready

Folder: \MyTasks
TaskName                                 Next Run Time          Status
======================================== ====================== ===============
Reboot                                   N/A                                 Ready
Reboot test                              Disabled

All these fail after completing once.

The history tab just shows that the tasks completed successfully.
Are you still receiving the "Selected Task "(0)" not longer exists" and "Catastrophic failure" error messages though?
Yes. How do I track down which task(s) are corrupted?
ok there seems to be something amiss here--it is not showing the run time--did it run the first time? Try this for me, where the user (/RU) is a domain admin
SCHTASKS /create /tn "Testing Reboot PC" /tr "c:\Windows\shutdown.exe -f -r -t 60" /sc daily /sd 11/29/2014 /st 17:00 /RU runasuser /RP userpassword
Ok, if you ran the schtasks-command elevated, maybe there are tasks only accessible by the system account. Anyway, to find out what tasks are corrupted, you start task scheduler, open the task library and (hopefully) you will receive error messages. Because at that time all tasks are parsed, errors would be found and corrupted tasks would be named - normally.
@lionelmm:  This computer is not  part of a domain.

@McKnife: I receive no errors when opening the library.
ok... but "Also when I click "Display all running tasks" I ger the error "Catastrophic Failure" persists?
then use SCHTASKS /create /tn "Testing Reboot PC" /tr "c:\Windows\shutdown.exe -f -r -t 60" /sc daily /sd 11/29/2014 /st 17:00 /U runasuser /P userpassword
I just followed a guide on how to remove all taks and registry keys for tasks and recreate them all. I left quite a few useless ones out. I recreated only the Microsoft ones. Now I get no Catastophic or  "Selected Task (0)" Errors.

Unfortunately, my reboot task will not even run manually through task scheduler now. I get err.txt
Now try again with the system account.
Ok. Setting the user to "system" fixed that-- and it appears to be working! The next ron time field displays what it should. I will test it for a couple days
Not sure why you had to set the user to SYSTEM to get it to run properly, I create Scheduled Tasks all the time to reboot servers and I've never had to set it to run as the SYSTEM account. At least it's working now though.

In the properties of the task, do you have the following options selected?
Run whether user is logged on or not
Tick Do not store password. The task will only have access to local computer resources.
Tick Run with highest privileges
Configure for: Windows 8.1
Where are your scripts located? Where is this "\MyTasks\Reboot Task". I would expect to see C:\MyTasks\Reboot Task.bat so why is it only "\MyTasks\Reboot Task" for location of the script
I think what's lisited in query are names and folders strictly internal to task scheduler. I only had the one batch file in the root directory  and I got rid of it anyway in favor of your command line, and the approach therein.

@McKnife: FYI the culprits, corrupted tasks were two AVG Free Updaters. And it told me which ones were corrupt when I did schtasks /query /fo CSV > tasklist.csv.

@VB_ITS: Maybe something got messed up with it's credentials or memory of passwords. Although I never even set a password prior to this.
See how you go with the task as it is. Are you able to confirm if the options in my previous post are selected/ticked?
Yes, they are tiked. Of course Run whether user is logged on or not is greyed out as well as Do not store password. The task will only have access to local computer resources.

Also this is Windows 7.

Run with highest privileges is tiked.
Thank you all  very much! It's working without a hitch.