Force a reboot after successful installation

//Force a reboot after successful installation
Force a reboot after successful installation 2017-02-13T18:27:51+00:00

The Toolkit Forums General Force a reboot after successful installation

  • Author
    Posts
  • Anwer
    Participant
    Post count: 10
    #1938 |

    I know I am probably over-looking this command in the toolkit but I have not been able to find the command to force a reboot after a successful installation.

    I have seen some reference online to “Restart-Computer -Force” but I am not sure if that will still return a successful exit code in the logs.

    What is the best practice to force the reboot in the script? I know that I can force it when using in SCCM, but I will be running this deploy-application.exe manually for now.

    Thanks.

  • Pelle
    Participant
    Post count: 100

    If you’re running it manually you could just create a CMD file as a wrapper, and trigger a restart after the script completes successfully.

    Something like this:

    @echo off
    Deploy-Application.exe
    if errorlevel 3010 (
    shutdown -r -t 0
    )

    Just adjust the If statement or remove it completely. Using a wrapper allows the installation to complete fully and finalize logging and such.

    Hope this helps

  • Jim
    Participant
    Post count: 45

    Show-InstallationRestartPrompt, has parameters for CountdownSeconds, CountdownNoHideSeconds and NoCountdown.

    • Pelle
      Participant
      Post count: 100

      Wasn’t sure if the Show-InstallationRestartPrompt would be able to actually force a reboot on timeout. But if that works, surely that’s a better alternative.

  • Anwer
    Participant
    Post count: 10

    Thanks.

  • Justin
    Participant
    Post count: 13

    In Deploy-Application.ps1 in the Post-installation phase include this as the last action. The script will reboot the machine and quit the script properly. If you create logs (see config XML) you can actually see when the reboot happend.

    If (($mainExitCode -eq 0) -OR ($mainExitCode -eq 3010)) {
    Show-InstallationRestartPrompt -NoCountdown
    }

You must be logged in to reply to this topic.