Jump to content
Katty

Flag an agent as having a reboot pending.

Recommended Posts

 

 

Labtech looks at two different registry keys/folders to see if a reboot is pending.

 

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending

 

If either of these keys/folders exist, then the machine is flagged as 1024. This is the "Reboot Needed" checkbox on the welcome tab of the agent. Labtech will check for these two registry keys each time the agent checks in.

 

This script will manually create the registry entry for first registry key. The second can be edited because by default the Administrators group only has read permissions. Only trustedinstaller has full control and the ability to create this key/folder.

 

 

 

Link to XML:

registrykey.jpg.428178bb08aa26d479c13e64013e7858.jpg

script.jpg.8c11ca3514e44d62959afaf32eb1c1d4.jpg

TRG - Production - Set Reboot Pending.zip

Share this post


Link to post
Share on other sites

Thanks again for this! It has been very helpful.

 

Something that may be worth noting is that I ended up having trouble with the registry key not being cleared upon rebooting the machine.

 

I modified the script to make it also create a scheduled task which runs at next boot.

 

The scheduled task deletes the RebootRequired registry key and then deletes itself.

 

AFAIK XML scheduled tasks are not able to be used in XP Class or older OSs, so this is not meant to be used on a Windows version in that category.

TG-Set Reboot Pending.zip

Share this post


Link to post
Share on other sites

I have a computer and below keys does not exist.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending

LabTech is still flagging it. I would add ( SELECT (Computers.Flags & 1024) FROM computers WHERE  computerid=%computerid% Not = 0, Then Jump to :ProceedReboot ) in addition to checking RebootRequired, and Reboot Pending key values. If those have no values, computer may still need a restart. SQL query will let you know if your system needs a reboot or not.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...