Go Back   TechArena Community > Technical Support > Computer Help > Windows Server > Windows Server Help
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Auto Shutdown and Restart

Windows Server Help


Reply
 
Thread Tools Search this Thread
  #1  
Old 21-03-2008
John
 
Posts: n/a
Auto Shutdown and Restart

Planning to schedule my Windows Server 2003 to auto shutdown and restart
(just one time) during non business hour. I'm going to use Task Scheduler to
accomplish this. I've never done it before so I have a question: what is the
command?

C:\Windows\System32\Shutdown.exe -r

is that sufficient? Do I need to provide reason for restart? Credentials to
run the command?

Thanks.



Reply With Quote
  #2  
Old 21-03-2008
lforbes
 
Posts: n/a
RE: Auto Shutdown and Restart

Hi,

For 2003 server you need a reason. It won't work with just the -r. If you
type the shutdown /? at the command line it will give you all the options.

shutdown -r -d p:0:0 shoud work. Test at the command line of a workstation.

Cheers,
Lara

"John" wrote:

> Planning to schedule my Windows Server 2003 to auto shutdown and restart
> (just one time) during non business hour. I'm going to use Task Scheduler to
> accomplish this. I've never done it before so I have a question: what is the
> command?
>
> C:\Windows\System32\Shutdown.exe -r
>
> is that sufficient? Do I need to provide reason for restart? Credentials to
> run the command?
>
> Thanks.
>
>
>

Reply With Quote
  #3  
Old 21-03-2008
Paul Bergson [MVP-DS]
 
Posts: n/a
Re: Auto Shutdown and Restart

I would suggest you reconsider using the shutdown command. I have had a lot
machines go stupid where they hang in the reboot process and you will
eventually have to hit the power switch to get them restarted. It is
intermittent and it works most of the time but I have since written a script
with an e-mail notification when it is rebooted.

I create a vbs from the script below (Make sure to replace the Your computer
name and your domain name) and enter it in the scheduled task as:
cscript e:\scriptname.vbs computerToReboot

We have many machines all scheduled using this same task (All run from a
single administrative machine) and are e-mailed when the reboot occurs. I
have never had an error since going this route.

Option Explicit

''''''''''''''''''''''''''''''''''''''''''''''''''

' Program - RemoteReboot.vbs '

' Author - Paul Bergson '

' Date Written - 04/15/07 '

' Description - Is a more drastic remote reboot '

''''''''''''''''''''''''''''''''''''''''''''''''''

Dim OpSysSet

Dim OpSys

Dim strComputer

Dim iMsg

Dim iConf

Dim Flds

Dim strSubject

Dim strHTML

on error resume next

strComputer = WScript.Arguments.Item(0) 'Get server name

If WScript.Arguments.Count = 1 Then

Set OpSysSet = GetObject("winmgmts:{(Shutdown)}\\" _

& strComputer _

& "\root\cimv2").ExecQuery("select * from Win32_OperatingSystem where
Primary=true")

For Each OpSys in OpSysSet

OpSys.Reboot()

Next

Else

Wscript.Echo "Server Name required. Reboot operation Aborted!"

Wscript.Quit

End If


'Send out an e-mail on the reboot

set imsg = createobject("cdo.message")

set iconf = createobject("cdo.configuration")

Set Flds = iConf.Fields

With Flds

..Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

..Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"smtp.YourDomain.com"

..Update

End With

strHTML = strComputer & " has been automatically rebooted by Your Computer
Name" _

& " on " & FormatDateTime(Date(),1) & ", " & FormatDateTime(Time(),3)

strSubject = strComputer & " has been rebooted"

With iMsg

Set .Configuration = iConf

..To = "NotificationName@YourDomain.com" ' Destination e-mail address

..From = "YourComputerName@YourDomain.com"

..Subject = strSubject

..HTMLBody = strHTML

..Send

End With

set imsg = Nothing

set iconf = Nothing


--
Paul Bergson
MVP - Directory Services
MCT, MCSE, MCSA, Security+, BS CSci
2008, 2003, 2000 (Early Achiever), NT4

http://www.pbbergs.com

Please no e-mails, any questions should be posted in the NewsGroup
This posting is provided "AS IS" with no warranties, and confers no rights.

"John" <a> wrote in message news:unXLj9siIHA.5412@TK2MSFTNGP02.phx.gbl...
> Planning to schedule my Windows Server 2003 to auto shutdown and restart
> (just one time) during non business hour. I'm going to use Task Scheduler
> to accomplish this. I've never done it before so I have a question: what
> is the command?
>
> C:\Windows\System32\Shutdown.exe -r
>
> is that sufficient? Do I need to provide reason for restart? Credentials
> to run the command?
>
> Thanks.
>



Reply With Quote
  #4  
Old 21-03-2008
John
 
Posts: n/a
Re: Auto Shutdown and Restart

I used "shutdown /r" without giving any reason. Scheduled it at 6:00 am this
morning. I just checked the log. It seems to do what it's supposed to.
Server restarted at 6:00 am.

Thanks for your reply anyway.

"lforbes" <lforbes@discussions.microsoft.com> wrote in message
news:30357FB9-DD92-4ABF-9529-A9B81D930D16@microsoft.com...
> Hi,
>
> For 2003 server you need a reason. It won't work with just the -r. If you
> type the shutdown /? at the command line it will give you all the options.
>
> shutdown -r -d p:0:0 shoud work. Test at the command line of a
> workstation.
>
> Cheers,
> Lara
>
> "John" wrote:
>
>> Planning to schedule my Windows Server 2003 to auto shutdown and restart
>> (just one time) during non business hour. I'm going to use Task Scheduler
>> to
>> accomplish this. I've never done it before so I have a question: what is
>> the
>> command?
>>
>> C:\Windows\System32\Shutdown.exe -r
>>
>> is that sufficient? Do I need to provide reason for restart? Credentials
>> to
>> run the command?
>>
>> Thanks.
>>
>>
>>



Reply With Quote
  #5  
Old 21-03-2008
John
 
Posts: n/a
Re: Auto Shutdown and Restart

I don't make it a habit to schedule unattended shutdowns or restarts. I did
it because software uninstallation needs a restart but I can't do that
during business hour. Therefore I scheduled a restart while no one is at the
office.

Thanks for the script below. Very much appreciated.

"Paul Bergson [MVP-DS]" <pbergson@allete_nospam.com> wrote in message
news:%23M0yEC1iIHA.4868@TK2MSFTNGP03.phx.gbl...
>I would suggest you reconsider using the shutdown command. I have had a
>lot machines go stupid where they hang in the reboot process and you will
>eventually have to hit the power switch to get them restarted. It is
>intermittent and it works most of the time but I have since written a
>script with an e-mail notification when it is rebooted.
>
> I create a vbs from the script below (Make sure to replace the Your
> computer name and your domain name) and enter it in the scheduled task as:
> cscript e:\scriptname.vbs computerToReboot
>
> We have many machines all scheduled using this same task (All run from a
> single administrative machine) and are e-mailed when the reboot occurs. I
> have never had an error since going this route.
>
> Option Explicit
>
> ''''''''''''''''''''''''''''''''''''''''''''''''''
>
> ' Program - RemoteReboot.vbs '
>
> ' Author - Paul Bergson '
>
> ' Date Written - 04/15/07 '
>
> ' Description - Is a more drastic remote reboot '
>
> ''''''''''''''''''''''''''''''''''''''''''''''''''
>
> Dim OpSysSet
>
> Dim OpSys
>
> Dim strComputer
>
> Dim iMsg
>
> Dim iConf
>
> Dim Flds
>
> Dim strSubject
>
> Dim strHTML
>
> on error resume next
>
> strComputer = WScript.Arguments.Item(0) 'Get server name
>
> If WScript.Arguments.Count = 1 Then
>
> Set OpSysSet = GetObject("winmgmts:{(Shutdown)}\\" _
>
> & strComputer _
>
> & "\root\cimv2").ExecQuery("select * from Win32_OperatingSystem where
> Primary=true")
>
> For Each OpSys in OpSysSet
>
> OpSys.Reboot()
>
> Next
>
> Else
>
> Wscript.Echo "Server Name required. Reboot operation Aborted!"
>
> Wscript.Quit
>
> End If
>
>
> 'Send out an e-mail on the reboot
>
> set imsg = createobject("cdo.message")
>
> set iconf = createobject("cdo.configuration")
>
> Set Flds = iConf.Fields
>
> With Flds
>
> .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
>
> .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
> "smtp.YourDomain.com"
>
> .Update
>
> End With
>
> strHTML = strComputer & " has been automatically rebooted by Your Computer
> Name" _
>
> & " on " & FormatDateTime(Date(),1) & ", " & FormatDateTime(Time(),3)
>
> strSubject = strComputer & " has been rebooted"
>
> With iMsg
>
> Set .Configuration = iConf
>
> .To = "NotificationName@YourDomain.com" ' Destination e-mail address
>
> .From = "YourComputerName@YourDomain.com"
>
> .Subject = strSubject
>
> .HTMLBody = strHTML
>
> .Send
>
> End With
>
> set imsg = Nothing
>
> set iconf = Nothing
>
>
> --
> Paul Bergson
> MVP - Directory Services
> MCT, MCSE, MCSA, Security+, BS CSci
> 2008, 2003, 2000 (Early Achiever), NT4
>
> http://www.pbbergs.com
>
> Please no e-mails, any questions should be posted in the NewsGroup
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
> "John" <a> wrote in message news:unXLj9siIHA.5412@TK2MSFTNGP02.phx.gbl...
>> Planning to schedule my Windows Server 2003 to auto shutdown and restart
>> (just one time) during non business hour. I'm going to use Task Scheduler
>> to accomplish this. I've never done it before so I have a question: what
>> is the command?
>>
>> C:\Windows\System32\Shutdown.exe -r
>>
>> is that sufficient? Do I need to provide reason for restart? Credentials
>> to run the command?
>>
>> Thanks.
>>

>
>



Reply With Quote
Reply

  TechArena Community > Technical Support > Computer Help > Windows Server > Windows Server Help
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Auto Shutdown and Restart"
Thread Thread Starter Forum Replies Last Post
Shutdown, Restart, or Log Off your computer using VB.Net Praetor Software Development 5 11-02-2014 06:44 PM
Windows XP won't restart from shutdown Myra Windows XP Support 3 19-03-2012 12:09 PM
Automatic Restart After Shutdown Gregoryl Windows XP Support 10 12-12-2011 10:46 AM
Windows does not Shutdown or Restart Curt Tips & Tweaks 0 08-11-2008 05:14 PM
Windows Restart automatically after shutdown Dave Vista Help 5 18-01-2008 04:23 AM


All times are GMT +5.5. The time now is 01:41 PM.