Shutdown Function

A script that allows you to close apps you have open and perform other tasks before shutdown.

  1. Regedit32
    The following is a simple function to allow the User time to close other programs they may have open, before the computer shuts down to perform tasks you may include in a Script you code.

    The Prompts that appear can be labelled. In this example they are labelled Modifications but you can use whatever information you like here, or nothing at all - that is your call.

    Note: If you want to test this in Windows PowerShell ISE, it will set the shutdown time to 2 minutes. To abort this automated shutdown, press Windows Key + R then in the run dialog type shutdown -a and click OK

    Code (PowerShell):
    Function RestartPrompt {
      $Prompt1 = [Microsoft.VisualBasic.Interaction]::MsgBox("Your computer needs to reboot. Please save and close any open work, if you wish to cancel the reboot please hit cancel.", "OKCancel,Information","Modifications")
      if ($Prompt1 -eq "Ok") {
        [Microsoft.VisualBasic.Interaction]::MsgBox("Reboot will occur in 2 minutes.", "OkOnly,Information","Modifications")
        shutdown /r /t 120
      if ($Prompt1 -eq "Cancel") {
        [Microsoft.VisualBasic.Interaction]::MsgBox("Reboot has been canceled.", "OKOnly,Information","Modifications")