Solved

Windows 7 64bit daily reboot

Posted on 2014-01-29
10
401 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
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:dlethe
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
 
LVL 23

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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When it comes to security, there are always trade-offs between security and convenience/ease of administration. This article examines some of the main pros and cons of using key authentication vs password authentication for hosting an SFTP server.
A procedure for exporting installed hotfix details of remote computers using powershell
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

757 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

19 Experts available now in Live!

Get 1:1 Help Now