Here’s a script that will check for and display any pending file rename operations. Windows stores the information on locked files that need to be renamed or deleted at startup. This is usually a result of an install or update that tries to replace files that are in use. This script was developed to use as a pre-installation step for a command line install routine that did not report pending file rename operations back to the user. If pending operations were found, the server was rebooted before the install was run. Using this script saved time and effort as the number of servers to be rebooted was known in advance of the install and could be handled more efficiently.
‘Programmer: Tom Mills/Microsoft Corp.
‘Purpose: Checks registry key for pending file rename operations
CONST HKEY_LOCAL_MACHINE = &H80000002
strComputer = “.”
strFileOps = “”
strComputer & “\root\default:StdRegProv”)
strKeyPath = “SYSTEM\CurrentControlSet\Control\Session Manager”
strValueName = “PendingFileRenameOperations”
Return = objReg.GetMultiStringValue(HKEY_LOCAL_MACHINE,strKeyPath,_
If (Return = 0) And (Err.Number = 0) Then
For Each strValue In arrValues
strFileOps = strFileOps & chr(13) & strValue
WScript.Echo “Pending File Rename Operations Found: ” & strFileOps
If Err.Number = 0 Then
Wscript.Echo “No Pending File Operations Found”
Wscript.Echo “Check Pending File Operations failed. Error = ” & Err.Number
Another (and more sophisticated approach) is to use Windows Powershell. The VBscript was developed for servers that did not have Powershell available.
Here’s some links to Powershell scripting info and SQL Server 2008 support for Powershell: