We've been using SCCM 2012 R2 to test deployments of Window 8.1 to UEFI-enabled Lenovo laptops. We found that when you image these laptops over and over again a new "Windows Boot Manager" entry is created as a boot option each time. After much hair pulling, we finally found a couple references to the issue:
http://technet.microsoft.com/en-us/library/cc749510(v=ws.10).aspx
http://jeff.squarecontrol.com/archives/184/comment-page-1#comment-355
In that second link, particularly the comment referenced, someone posted a VBS that will use WMI to automatically clean up firmware boot loader entries. This would be great since we could just add a task sequence step during SCCM OSD, and not have to do it manually like the Technet entry wants us to.
The problem is I'm not great with scripting, and can usually get by modifying someone else's script. This time, however, I can't get this one to work for the life of me. So you don't have to keep looking at the second link, here's the contents of the script:
option explicit
dim strComputer
dim strFilePath
dim objLocator
dim objRootWMI
dim objBCD
dim objBCDStore
dim objFWBL
dim colObjects
dim objElement
dim strTemp
Const BcdLibraryString_Description = &h12000004
Const Firmware = &h101FFFFF
strComputer = “.”
strFilePath = “TEMPSTORE”
‘Connect to WMI
set ObjLocator = CreateObject(“WbemScripting.SWbemLocator”)
set objRootWMI = ObjLocator.ConnectServer(strComputer, “root\wmi”)
objRootWMI.Security_.ImpersonationLevel = 3
strTemp = “winmgmts:{impersonationlevel=Impersonate,(Backup,Restore)}!root/wmi:BcdStore”
‘———————————————————————-
‘ Open the BcdStore.
‘———————————————————————-
set objBCD = GetObject( strTemp )
if Err.number 0 then
WScript.Echo “ERROR: GetObject(” & strTemp & “) failed rc=” & Hex(Err.number) & ” ” & Err.Description’
WScript.Quit(1)
end if
if not objBCD.OpenStore(strFilePath, objBcdStore ) then
WScript.Echo “ERROR: Could not open the BCD system store.”
WScript.Quit(1)
end if
set objBCD = nothing
‘———————————————————————-
‘ Enumerate the Firmware Boot Manager.
‘———————————————————————-
if not objBcdStore.EnumerateObjects(Firmware, colObjects ) then
WScript.Echo “ERROR: objBcdStore.EnumberateObjects( Firmware ) failed.”
WScript.Quit(1)
end if
for each objFWBL in colObjects
if not objFWBL.GetElement( BcdLibraryString_Description, objElement ) then
WScript.Echo “ERROR: Firmware Boot Loader GetElement for ” & Hex(BcdLibraryString_Description) & ” failed.”
WScript.Quit(1)
end if
if not BcdStore.DeleteObjectobjFWBL.Id) then
WScript.Echo “ERROR: Could not delete Firmware Boot Loader Item: ” & objElement.String
WScript.Quit(1)
end if
WScript.Echo “Deleted Firmware Boot Loader Item: ” & objElement.String
next
set objFWBL = nothing
set objBcdStore = nothing
set objLocator = nothing
set objRootWMI = nothingAfter pasting that into VBSedit the first thing I did was fix all the quotation marks that invariably get jacked up when copy/pasting from webpages. I also noticed a random single quote mark at the end of line 35 that I figured was a typo, so I removed it:
WScript.Echo “ERROR: GetObject(” & strTemp & “) failed rc=” & Hex(Err.number) & ” ” & Err.Description’
However, after that got fixed, I'm still getting an error "script.vbs (34, 15) Microsoft VBScript compilation error: Expected 'Then'". I'm guessing that line 34 needs some kind of logical operator for the "If Err.number 0 then" statement. But, I can't figure out what it would be, i.e. <> 0, = 0, etc.
Just to play around with it I tried both, and still get errors regarding line 35. So, I'm guessing something is really messed up around there. I would really appreciate anyone that could give me some guidance as my forehead is sore from banging it into the keyboard. Thanks.