?
Solved

Windows 7 64bit daily reboot

Posted on 2014-01-29
10
Medium Priority
?
435 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

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

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…
This program is used to assist in finding and resolving common problems with wireless connections.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Suggested Courses

770 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