Solved

Windows 7 64bit daily reboot

Posted on 2014-01-29
10
423 Views
Last Modified: 2014-02-11
I need to create a script for daily reboot on all Windows 7 64bit PC's. What is the best way to do this?
If you do it via Group Policy Schedule Tasks, it is not creating ST on PC's. If you do it as Startup script to create ST via GP it is still not doing it. Here is the command I use to create .bat file and then put this in GP under Startup scripts:
"schtasks.exe /create /SC DAILY /TN reboot /TR "C:\windows\system32\shutdown.exe -f -r -t 00" /ST 02:00"
I did verified and it creates task when run locally so script is ok.
I am not sure what am I missing? Even if it was doing it via ST, I do not think this would be the best way to handle this because, what about PC's that none logs onto but you still want them to reboot daily regardless?
0
Comment
Question by:MRS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 44

Expert Comment

by:Darr247
ID: 39817963
It's probably not being created because the user that logs on doesn't have sufficient permission/access to create a scheduled task (only Admin-level users can create scheduled tasks).  I think you also must specify a /p [password] when creating a ST like that, unless you also use /ru System to make it run with System permissions/security.


Could you use the Request Attention link to ask the admins here to add the appropriate server OS as an additional topic area?   That should be sure to get the attention of experts that monitor those specific topic areas.
0
 

Author Comment

by:MRS
ID: 39818006
I have admin right on every pc (part of admin group), so by me creating task, not sure why is it not accepting it via GP. Again if I run this script locally and check my ST it is there.
Sure. I will ask admins to add a topic. Thanks.
0
 
LVL 47

Expert Comment

by:David
ID: 39828708
Well, technically you can't ever have a script that insures that the system will always reboot if somebody is logged on.

That is due to the possibility that some of the services running will fail to stop because an application is running that uses them and shutdown triggers one of those are-you-sure things.

So to tackle the problem you must make sure you have policy that people log off, and even then you need to allow for the program not working because of resources.

I know this isn't a solution for you, but you need to consider that no matter what you script it will not be infallible.

To insure a shutdown, you need to have some sort of a watchdog timer or  board in the computer.
0
Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

 
LVL 25

Expert Comment

by:Coralon
ID: 39828742
I'd probably set up a scheduled task from another machine to handle this.   I'd create a list of those machines, and pipe it into a for command.

for /f %f in (computers.txt) do shutdown /r /t 0 /f /m \\%f

You can create your computers.txt by an automation script.  The only key of course would be making sure you only got the machines you wanted.  I'm sure it could be done fairly easily in powershell.  If you had them separated into their own OU, it'd be simple.
get-adcomputer -filter * -searchbase "ou=x64computers,dc=domain,dc=local 

Open in new window


I'm sure it could be done with dsquery also, but it'd probably be trickier.

By doing all of this from a separate machine, you shouldn't have much trouble making it work, and even if they are logged in, it will be forced off.

Coralon
0
 

Author Comment

by:MRS
ID: 39838611
@Coralon
This might work but only thing is that WinRM service has to run on each PC. How do you ensure that WinRm is running on 500+ PC's or not running and if not running how to start it remotely?
0
 

Author Comment

by:MRS
ID: 39838758
I think I will use PsExec. So I will create powershell script that resides on server and that  will call PsExec from server and feed list of PC names. Once I connect to their cmd.exe just run shutdown -r -f -t 00 command and that's it. It should work as a charm regardless of the OS type or version or architecture. Simple and powerful. Will work on it today and let you know if doable or not.
0
 

Accepted Solution

by:
MRS earned 0 total points
ID: 39838911
Ok I did this. Sometimes simple solutions work well:

Create reboot.bat file on each PC on root drive with line "shutdown -r -f -t 00"

Create PowerShell script with lines:

$compname = Get-content c:\list.txt
\\"PCName"\Sysinternals\PSTools\psexec.exe \\$compname c:\reboot.bat


"PCname"=path where psexec.exe resides
(I can also query AD for list of PC's instead feed them as txt file, as we have them in separate OU)
This way we have a reboot process and just run it every night in Schedule Task.
Simple isn't it!
0
 

Author Comment

by:MRS
ID: 39840039
Considering that all PC's have C:\reboot.bat do  PowerShell script with:
Get-content c:\test.txt | foreach {
\\"ComputerName"\Sysinternals\PSTools\psexec.exe \\$_ c:\reboot.bat
0
 

Author Closing Comment

by:MRS
ID: 39849665
Because it is the only solution that works well without considering architecture of the PC and simplest one.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article shows how to use a free utility called 'Parkdale' to easily test the performance and benchmark any Hard Drive(s) installed in your computer. We also look at RAM Disks and their speed comparisons.
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

688 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