'Harlan Brumm, Global Technical Lead Revit Architecture - Product Support 'Autodesk, Inc. 2010 'This Script resets the Revit Architecture 2011 User Interface by renaming or deleting UIState.dat (based on user choice) and deletes the Project Browser Regristy key. Option Explicit On Error Resume Next DIM objFSO DIM objFLO DIM strFilePath Dim objShell Dim regLogonUserName Dim LogonUserName DIM strComputer DIM objReg DIm strKeyPath DIM objRegistry DIM arrSubkeys DIM strpromptRQAT DIM strTitleRQAT DIM intBTNRQAT DIM intRTNRQAT DIM strpromptPB DIM strTitlePB DIM intBTNPB DIM intRTNPB Dim strPromptRQAT1 Dim strTitleRQAT1 DIM intBTNRQAT1 DIM intRTNRQAT1 DIM strPromptRQAT2 DIM strTitleRQAT2 DIM intBTNRQAT2 DIM intRTNRQAT2 DIM strPromptStart DIM strTitleStart DIM intBTNStart DIM intRTNStart DIM strNewFile DIM objWMI DIM objFile DIM intRC DIM objWMIService DIM colProcesses DIM objProcess DIM strPromptRun DIM strTitleRun DIM intRTNRun 'Setting up Presets and determine using login name strComputer = "." regLogonUserName = "HKEY_CURRENT_USER\Volatile Environment\HOMEPATH" Set objShell = WScript.CreateObject("WScript.Shell") LogonUserName = objShell.RegRead(regLogonUserName) Set objFLO = CreateObject("Scripting.FileSystemObject") 'Verifying Vista or XP and setting correct paths for UIState.dat If objFLO.FolderExists ("c:\Users") Then strFilePath = "C:" & LogonUserName & "\AppData\Local\Autodesk\Revit\Autodesk Revit Architecture 2011\UIState.dat" Else strFilePath = "C:" & LogonUserName & "\Local Settings\Application Data\Autodesk\Revit\Autodesk Revit Architecture 2011\UIState.dat" End If 'Setting name for renamed UIState.dat If strFilePath = "c:" & LogonUserName & "\AppData\Local\Autodesk\Revit\Autodesk Revit Architecture 2011\UIState.dat" then strNewFile = "C:" & LogonUserName & "\AppData\Local\Autodesk\Revit\Autodesk Revit Architecture 2011\UIState.dat." & Year(Now()) & Month(Now()) & Day(Now()) & Hour(Now()) & Minute(Now()) & Second(Now()) Else strNewFile = "C:" & LogonUserName & "\Local Settings\Application Data\Autodesk\Revit\Autodesk Revit Architecture 2011\UIState.dat." & Year(Now()) & Month(Now()) & Day(Now()) & Hour(Now()) & Minute(Now()) & Second(Now()) End If 'Checking to make sure that Revit.exe process is not running Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process") For Each objProcess in colProcesses If Right(objProcess.Name, 9) = "Revit.exe" Then strPromptRun = "This script can only be run when Autodesk Revit based products are closed. Please close Autodesk Revit based products and run this tool again. There may occur a delay between closing Autodesk Revit based products and being allowed to run this script" strTitleRun = "Revit.exe is running..." intRTNRun = MsgBox(strPromptRun, vbOkonly+VBCritical,strTitleRun) Wscript.Quit End If Next 'Renaming UIState.dat strPromptStart = "WARNING!! You are about to reset your Autodesk Revit Architecture 2011 User Interface. Ensure that you run this script with ADMIN privileges. Do You Wish to Continue?" strTitleStart = "Reset Ribbon, Quick Access Toolbar and Project Browser" intRTNStart = MsgBox(strpromptStart,vbYesNo+VBExclamation,strTitleStart) If intRTNStart = vbYes Then strPromptRQAT = "You can now reset your Ribbon and Quick Access Toolbar. Are you sure you wish to continue?" strTitleRQAT = "Reset the Autodesk Revit Architecture 2011 Ribbon and Quick Access Toolbar" intBTNRQAT = 4 '4 is yes/no 3 is yes/no/cancel intRTNRQAT = MsgBox(strpromptRQAT, vbYesNo+VBQuestion,strTitleRQAT) If intRTNRQAT = vbYes Then strPromptRQAT1 = "Do you wish to create a Backup of your existing User Interface? Selecting Yes will rename your User Interface file with todays date and time. Selecting No will delete your User Interface file." strTitleRQAT1 = "Reset Autodesk Revit Architecture 2011 Ribbon and Quick Access Toolbar" intBTNRQAT1 = 4 '4 is yes/no 3 is yes/no/cancel intRTNRQAT1 = MsgBox(strpromptRQAT1, vbYesNo+VBQuestion,strTitleRQAT1) If intRTNRQAT1 = vbYes Then set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") set objFile = objWMI.Get("Cim_Datafile='" & strFilePath & "'") WScript.Echo "Renaming " & strFilePath intRC = objFile.Rename(strNewFile) if intRC <> 0 then WScript.Echo "There was an error renaming the file: " & intRC else WScript.Echo "Successfully reset Autodesk Revit Architecture 2011 Ribbon and Quick Access Toolbar" end if Else WScript.Echo "Deleting " & strFilePath set objFSO = CreateObject("Scripting.FileSystemObject") objFSO.DeleteFile(strFilePath) WScript.Echo "Successfully reset Autodesk Revit Architecture 2011 Ribbon and Quick Access Toolbar" End If Else WScript.Echo "Autodesk Revit Architecture 2011 Ribbon and Quick Access Toolbar have not been reset" End If 'Resetting location of browsers back to OOTB. strPromptPB = "You can now reset the location of your Project Browser. Are you sure you wish to continue? This will delete a registry key on your computer." strTitlePB = "Reset the Autodesk Revit Architecture 2011 Project Browser" intRTNPB = MsgBox(strpromptPB, vbYesNo+VBQuestion,strTitlePB) If intRTNPB = vbYes Then Const HKEY_CURRENT_USER = &H80000001 strKeyPath = "Software\Autodesk\Revit\Autodesk Revit Architecture 2011\Components\Panels" Set objRegistry = GetObject("winmgmts:\\" & _ strComputer & "\root\default:StdRegProv") WScript.Echo "Deleting HKEY_CURRENT_USER\Software\Autodesk\Revit\Autodesk Revit Architecture 2011\Components\Panels" DeleteSubkeys HKEY_CURRENT_USER, strKeypath Sub DeleteSubkeys(HKEY_CURRENT_USER, strKeyPath) objRegistry.EnumKey HKEY_CURRENT_USER, strKeyPath, arrSubkeys If IsArray(arrSubkeys) Then For Each strSubkey In arrSubkeys DeleteSubkeys HKEY_CURRENT_USER, strKeyPath & "\" & strSubkey Next End If objRegistry.DeleteKey HKEY_CURRENT_USER, strKeyPath End Sub WScript.Echo "Successfully Reset Autodesk Revit Architecture 2011 Project Browser" Else WScript.Echo "Autodesk Revit Architecture 2011 Project Browser has not been reset" End If WScript.Echo "Script Complete" Else WScript.Echo "Script Canceled" End If