Jump to content
Sign in to follow this  
Exit

Prevent auto reboot when a user is logged in.

Recommended Posts

Yes, it caught me again tonight. :ranting:

While a VHS tape has been copied to the hard disk, after 3.5 hours (30 minutes before the end) Windows has automatically rebooted after an update.
That although activity was present. Thanks Micro scrap.

Now I've created this script so it never happens again.
Maybe it will help you too.

Thanks to @argumentum for this new version.

; Switch off AutoReboot after Windows update
; Author: Exit   ( http://www.autoitscript.com/forum/user/45639-exit )

; Windows Registry Editor Version 5.00
; [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU]
; "NoAutoRebootWithLoggedOnUsers"=dword:00000001

#RequireAdmin ; otherwise error 1

Local Const $sRegkeyname = "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU"
Local Const $sRegValuename = "NoAutoRebootWithLoggedOnUsers"
Local $iAutoReboot = RegRead($sRegkeyname, $sRegValuename)
Switch @error
    Case 0
    Case 1, 2, -1
        $iAutoReboot = 0
    Case Else
        Exit MsgBox(64 + 262144, Default, "Error  " & @error & " reading registry.", 0)
EndSwitch
If $iAutoReboot = 1 Then
    MsgBox(64 + 262144, Default, $sRegValuename & " switch was already ON." & @LF & @LF & "No further action required.", 0)
Else
    Local $rc = RegWrite($sRegkeyname, $sRegValuename, "REG_DWORD", 1)
    If @error Then Exit MsgBox(64 + 262144, Default, "Error " & @error & " writing registry." & @LF & @LF & "#RequireAdmin missing?", 0)
    MsgBox(64 + 262144, Default, "NoAutoRebootWithLoggedOnUsers switch set ON." & @LF & @LF & "No AutoReboot will occour while you are logged on.", 0)
EndIf

Previous code in Spoiler.

Spoiler
; Switch off AutoReboot after Windows update
; Author: Exit   ( http://www.autoitscript.com/forum/user/45639-exit )

; Windows Registry Editor Version 5.00
; [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU]
; "NoAutoRebootWithLoggedOnUsers"=dword:00000001

#RequireAdmin ; otherwise error 1

Local Const $sRegkeyname = "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU"
Local Const $sRegValuename = "NoAutoRebootWithLoggedOnUsers"
Local $iAutoReboot = RegRead($sRegkeyname, $sRegValuename)
If @error Then Exit MsgBox(64 + 262144, Default, "Error reading registry.", 0)

If $iAutoReboot = 1 Then
    MsgBox(64 + 262144, Default, $sRegValuename & " switch was already ON." & @LF & @LF & "No further action required.", 0)
Else
    Local $rc = RegWrite($sRegkeyname, $sRegValuename, "REG_DWORD", 1)
    If @error Then Exit MsgBox(64 + 262144, Default, "Error " & @error & " writing registry." & @LF & @LF & "#RequireAdmin missing?", 0)
    MsgBox(64 + 262144, Default, "NoAutoRebootWithLoggedOnUsers switch set ON." & @LF & @LF & "No AutoReboot will occour while you are logged on.", 0)
EndIf

 

 

Edited by Exit

App: Au3toCmd              UDF: _SingleScript()                             

Share this post


Link to post
Share on other sites

Wish I knew about this when I was using Windows... I am sure some will find this very useful :)

My story is about the same, but it was a long game installation instead of copying. I had to wipe the existing install (because I was away and not sure if it was installed properly) and do it again, fun times.


EasyCodeIt - A cross-platform AutoIt implementation

DcodingTheWeb Forum - Follow for updates and Join for discussion

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...