Bad boy Warrior Posted December 14, 2006 Share Posted December 14, 2006 Is it possible to reboot all PCs whether a user is logged on or not using a group policy task scheduler? i know how to set up the task via policy but cant workout how to restart all pcs.....so far i have:echo shutdown -rat 01:00 /every:01this is in a batch file that runs when the system starts. I would like to restart everyday at 1amthanks Link to comment Share on other sites More sharing options...
jaclaz Posted December 14, 2006 Share Posted December 14, 2006 Is it possible to reboot all PCs whether a user is logged on or not using a group policy task scheduler? i know how to set up the task via policy but cant workout how to restart all pcs.....so far i have:echo shutdown -rat 01:00 /every:01this is in a batch file that runs when the system starts. I would like to restart everyday at 1amthanksWell, actually that line in a batch:echo shutdown -rat 01:00 /every:01does not make much sense, the first line will ECHO to the screen the string "shutdown -r", and the second line is missing the actual COMMAND that needs to be executed, besides the missing "\\computername"See here the correct syntax for the AT command:http://www.ss64.com/nt/at.htmlAs reported there, AT is an old command, the "new" one is SCHTASKS:http://www.ss64.com/nt/schtasks.htmlAnd shutdown.exe has more options, doing a shutdown of remote computers without checking them can lead to either a "not performed" shutdown (i.e. the user stopped the countdown) or a "bad" shutdown, where services or applications are not closed properly, that could lead to data leak:http://www.ss64.com/nt/shutdown.htmlPersonally I would use PSShutdown:http://www.microsoft.com/technet/sysintern...PsShutdown.mspxthat has more options, including one to shutdown every computer in the Domain (\\*).With all due respect, judging from your questions, here and on this other thread:http://www.msfn.org/board/index.php?showtopic=88691&hl=you might want to study a little bit more about batch language and more generally commands in NT/2K/XP before attempting using them.The two already referenced sites:http://www.robvanderwoude.com/index.htmlhttp://www.ss64.com/are very good starting points.jaclaz Link to comment Share on other sites More sharing options...
Bad boy Warrior Posted December 15, 2006 Author Share Posted December 15, 2006 (edited) Is it possible to reboot all PCs whether a user is logged on or not using a group policy task scheduler? i know how to set up the task via policy but cant workout how to restart all pcs.....so far i have:echo shutdown -rat 01:00 /every:01this is in a batch file that runs when the system starts. I would like to restart everyday at 1amthanksWell, actually that line in a batch:echo shutdown -rat 01:00 /every:01does not make much sense, the first line will ECHO to the screen the string "shutdown -r", and the second line is missing the actual COMMAND that needs to be executed, besides the missing "\\computername"See here the correct syntax for the AT command:http://www.ss64.com/nt/at.htmlAs reported there, AT is an old command, the "new" one is SCHTASKS:http://www.ss64.com/nt/schtasks.htmlAnd shutdown.exe has more options, doing a shutdown of remote computers without checking them can lead to either a "not performed" shutdown (i.e. the user stopped the countdown) or a "bad" shutdown, where services or applications are not closed properly, that could lead to data leak:http://www.ss64.com/nt/shutdown.htmlPersonally I would use PSShutdown:http://www.microsoft.com/technet/sysintern...PsShutdown.mspxthat has more options, including one to shutdown every computer in the Domain (\\*).With all due respect, judging from your questions, here and on this other thread:http://www.msfn.org/board/index.php?showtopic=88691&hl=you might want to study a little bit more about batch language and more generally commands in NT/2K/XP before attempting using them.The two already referenced sites:http://www.robvanderwoude.com/index.htmlhttp://www.ss64.com/are very good starting points.jaclazOk Mr Jaclaz, i see what you mean after thinking about it and reading on it i have come up with the below code:Schtasks /Create /SC Daily /RU System /MO 7 /TN TestReboot /TR "\\server\share$\task\psshutdown -r" /st 00:40:00 /SD 15/12/2006This works i.e. adds the task in the scheduler but the status comes up as Could not Start. Im logged on as administrator (for testing) and have copied relevant .dll and exe to the same folder. If i type psshutdown -r via the command line - it works.Thanksedit: I have also tried to replace \\server\share$\task\psshutdown -r with C:\windows\system32\shutdown -r with the same issue. I checked the Schedlgu.txt file and have 0x80070002 The system cannot find the file specified. Try using the task page browse button to locate the application, but reading on this error Edited December 15, 2006 by Bad boy Warrior Link to comment Share on other sites More sharing options...
jaclaz Posted December 15, 2006 Share Posted December 15, 2006 Try this:Schtasks /Create /SC Daily /RU System /MO 7 /TN TestReboot /TR "\\server\share$\task\testshut.cmd" /st 00:40:00 /SD 15/12/2006and create in \\server\share$\task\A file named testshut.cmd with this contents:@echo offpsshutdown -rThat should work, the problem is that you cannot pass parameters with the /TR switch, you can only give it a file to execute.jaclaz Link to comment Share on other sites More sharing options...
chilifrei64 Posted December 15, 2006 Share Posted December 15, 2006 Here is what I use. It is a script which runs on.. really any machine which will remotely log off/ shutdown/restart all computers in an OU which you specify. Then just schedule this once on whatever computer and it will do its taskhttp://lazynetworkadmin.com/content/view/36/6/ Link to comment Share on other sites More sharing options...
allen2 Posted December 16, 2006 Share Posted December 16, 2006 Also i don't think the system user will have acces to \\server\share$\task\. So it'll never run. You have to use either an account with ntfs and share rights on \\server\share$\task\ or copy the files needed on each computer. Link to comment Share on other sites More sharing options...
Bad boy Warrior Posted December 18, 2006 Author Share Posted December 18, 2006 Thanks everyone!!@JaclazI tried that but still didnt work In my tasks directory i havepdh.dllpsshutdown.exetestshut.cmdStartTask.batDoubleclick startask.bat and runs fine - adds the entry to task scheduler. But when the time comes it shows up an error "could not start" with the same error as before. Changed testshut.cmd to a .bat file - same error changed both files to .cmd and although they run by the command line without a problem they dont run as they should by a task and both run with a .bat extension if i double click them. The directory is in a test directory for now it does have full admin rights and im running as a domain admin.thanks Link to comment Share on other sites More sharing options...
jaclaz Posted December 18, 2006 Share Posted December 18, 2006 (edited) Well, if I get it right you have some problems with .cmd files.A batch file should run if double clicked BOTH if it has .bat or .cmd extension.Once you have fixed the above, you might want to try with this batch (that has no external commands):@ECHO OFFSETLOCAL ENABLEEXTENSIONSECHO Hallo, I am a batch file, and I am running!ECHO.ECHO I was invoked as %0, but my real name is %~nx0....ECHO.ECHO ...and, to be picky, my FULL name is %~f0ECHO-ECHO I live in directory %~dp0 and I'll terminate myselfECHO as soon as you press any key.PAUSEIf the above works, and it should, modify your testshut.cmd (or testshut.bat) as follows:@ECHO OFFSETLOCAL ENABLEEXTENSIONSECHO Hallo, I am a batch file, and I am running!ECHO.ECHO I was invoked as %0, but my real name is %~nx0....ECHO.ECHO ...and, to be picky, my FULL name is %~f0ECHO-ECHO I live in directory %~dp0, and I'm going to run %~dp0psshutdown -rECHO as soon as you press any key.PAUSE%~dp0psshutdown -rIf it did not work, try using more "common" paths, like the ones given in the example by MS:http://www.microsoft.com/resources/documen...s.mspx?mfr=trueC:\Appsif it works, it is a problem in the PATH given as "\\server\share$\task\"jaclaz Edited December 18, 2006 by jaclaz Link to comment Share on other sites More sharing options...
Bad boy Warrior Posted December 19, 2006 Author Share Posted December 19, 2006 It finally worked. Everything was ok except for one problem..........psshutdown -r should have been psshutdown.exe -r.Thanks for all your help Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now