This Blog


1E Blog

Empowering Efficient IT

Machines awaiting reboot due to “pending file rename operation”


As we know, many desktop computers do not get rebooted for long periods of time and many laptop users almost never shutdown their computer and just merely “close the lid”.  Because of this, the “pending reboot/file rename” is persisted and usually goes undetected.  Case-in-point:  After implementing this at a customer site, more than half of their computers needed to be rebooted due to a pending file rename…and they never knew it.

A “pending file rename operation” occurs when an install needs to rename files that are in-use at the time of the install, and is waiting to have the rename completed as part of the next reboot.  Some applications will first check to see if this condition exists before installing it’s app or software (some hotfixes will not install because of this).  This is a common practice amongst software patches and updates, service packs and anti-virus updates just to name a few.

To make this very (fun) practical and to ease your administrative duties, I’m going to provide instructions to implementing a solution that will “dynamically automate” (aahh…longtime FAVORITE phrase in IT!!!) the rebooting of all computers - running desktop OS’es -, that are awaiting a reboot due to “pending file rename operation”.

  • Create a package to reboot computers
  • Create and Assign an advertisement to the collection to reboot the computers

Create a package to reboot computers


Package program properties
Download GracefuLReboot.vbs (by Steve Pruitt)and use it as the source-files for the package.  Then create a package program with the Command-Line property as GracefuLReboot.vbs n (e.g. “n” being a numeric value for the amount of time to surpass before (re)prompting the logged-on user to reboot, should they decline during the previous attempt.  In my screen-capture below, I used “1” to represent prompting the logged-on user every 1 minute.  This is ok since it is just my lab environment.  If you want to prompt users every 60 minutes should they decline the reboot, then make the numeric value 60.  Keep in mind, this parameter only applies when NightWatchman is NOT installed on target computer.  If NightWatchman is installed, the n parameter is not used).

Overview of how the script chooses the reboot process

The script first checks to see if NightWatchman is installed.  If NightWatchman is installed, it run the following command-line:

nightwatchman.exe -onceoff -shutdowntime=NOW -shutdownaction=reboot

If NightWatchman is NOT installed, then the script will use the WMI Win32Shutdown method to reboot the computer.  Here is the VBscript code which calls the method:

Sub RebootComputer(ByVal intTimeOut, ByVal intFlags)

'Set objArgs = Wscript.Arguments

'intTimeOut = objArgs(0) 'Countdown in seconds
'intFlags = objArgs(1) 'Bitmapped set of flags to shutdown the computer: 0 = Logoff, 4 = Forced Logoff (0+4),
        '1 = Shutdown, 2 = Reboot, 6 = Forced Reboot (2+4), 8 = Power Off, 12 = Forced Power Off (8+4)

intTimeOutSec = intTimeOut * 1000 'Convert from milliseconds to seconds

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
  & "{impersonationLevel=impersonate,(Shutdown)}!\\" & _
   strComputer & "\root\cimv2")

Set colOperatingSystems = objWMIService.ExecQuery _
  ("Select * from Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
  Wscript.Sleep intTimeOutSec 'Pause for x seconds before rebooting computer
  objOperatingSystem.Win32Shutdown intFlags

End Sub

Create and Assign an advertisement to the collection to reboot the computers

Note: I want to stress that the advertisement properties below recommends using Always rerun program.  This option is only available under ConfigMgr.  If you are interested in a blog specifically for SMS, post a comment below.

Advertisement Schedule-tab properties
Now that the reboot package is created, create an advertisement of it and assign to the collection All Windows Workstation and Professional Systems (Note: More than likely, you will only want this executed against computers running desktop operating systems, so assigning the advertisement to this collection should be fine for you.)  On the Schedule tab for the advertisement properties, set a mandatory assignment with a recurring schedule of your choice (this will vary, depending on how aggressive you want to be.  Since this is my lab, I have it scheduled to run every 2 minutes.  However, in a production environment, the advert run every few hours or maybe once per day should be fine).  Since you are setting a recurring schedule for the advertisement, ConfigMgr will prompt you and recommend setting the Program rerun behavior to Always rerun program (Note: With this, the advertisement will run again even if it has previously run on the target computer).

Also, make sure Enable Wake On LAN is disabled (e.g. unchecked).  This will prevent ConfigMgr or 1E WakeUp from unnecessarily waking machines.

Impact of NightWatchman properties: MonitorJobs and PendingJobWindowMins

As explained, if NightWatchman is installed, the reboot script will use NightWatchman to reboot the computer.  When NightWatchman is initially installed on your computers, the property MonitorJobs is enabled (default) and PendingJobWindowMins is set to 5 minutes (default).  This combination means, if NightWatchman detects any currently running jobs in SMS/ConfigMgr and/or pending jobs in SMS/ConfigMgr within the specified “look-ahead” window (e.g. 5 minutes), the reboot/restart will be deferred.  If no jobs are currently running, or pending within the time specified by PendingJobWindowMins, the reboot/restart will occur.


Rebooting computers is one of those administrative tasks that’s at the top of the list.  As we all have been working with Windows for quite some time now, we know that rebooting is just a “good” thing to do.  Rebooting computers due to pending file rename operations, is a scenario that usually goes undetected in many environments.

Automated rebooting of computers is always a “hot topic” and usually requires buy-in from management.  While this blog may not show you how to navigate the approval process in your company, it does provide you the tools and instructions to implement this most valuable solution.  <wink>Once you get approval…</wink>

I hope you enjoyed…

Read the complete post at

Copyright -, Inc. - 2010 All Rights reserved.
Powered by Community Server (Commercial Edition), by Telligent Systems