'********************************************************************** '*** Name: SampleSetBootOrder.vbs '*** Purpose: To set the Boot Order on a Dell OMCI client. '*** Usage: cscript.exe //nologo SampleSetBootOrder.vbs '*** '*** This sample script is provided as an example only, and has not been '*** tested, nor is warranted in any way by Dell; Dell disclaims any '*** liability in connection therewith. Dell provides no technical '*** support with regard to such scripting. For more information on WMI '*** scripting, refer to applicable Microsoft documentation. '*** NOTE: Replace in line 70 (inside the quotes) '*** with the desired values if there is any password set in the system. '*** If both passwords(Admin and Boot) are set please replace it with Admin Password. '*** If there is no password set in the system please leave it as empty. '*** Please provide the new boot order from line 61. '*** See comments from line 58. '********************************************************************** Option Explicit '*** Declare variables Dim strNameSpace Dim strComputerName Dim strClassName Dim strClassNameOrder Dim objInstance Dim objInstanceOrder Dim strNewOrder() Dim strOldOrder() Dim strNewOrderInput(5) Dim strAuthorizationToken Dim returnValue Dim objWMIService Dim ColSystem Dim ColSystemOrder Dim oInParams Dim arraySize Dim arrayIndex Dim i Dim j '*** Check that the right executable was used to run the script '*** and that all parameters were passed If (LCase(Right(WScript.FullName, 11)) = "wscript.exe" ) Or _ (Wscript.Arguments.Count < 1) Then Call Usage() WScript.Quit End If '*** Initialize variables strNameSpace = "root/dcim/sysman" strComputerName = WScript.Arguments(0) strClassName = "DCIM_BootConfigSetting" strClassNameOrder = "DCIM_OrderedComponent" arraySize = 0 arrayIndex = 0 returnValue = 0 '*** Please provide the new order below to the strNewOrderInput '*** The order will be array index. The value of array will be the number in the Instance ID '*** in DCIM_BootSourceSetting. Following values are just a example. strNewOrderInput(0)="0" strNewOrderInput(1)="1" strNewOrderInput(2)="2" strNewOrderInput(3)="3" strNewOrderInput(4)="4" strNewOrderInput(5)="5" '*** Admin or Boot password input here strAuthorizationToken = "" '*** Retrieve the instance of DCIM_OrderedComponent class Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate," &_ "AuthenticationLevel=pktprivacy}\\" & strComputerName & "\" &_ strNameSpace) Set ColSystemOrder=objWMIService.execquery ("Select * from " & strClassNameOrder) '*** Assign the string with contains the instance ID in PartComponent to strOldOlder array of strings For each objInstanceOrder in ColSystemOrder arraySize = arraySize + 1 Next 'redefine the array for the correct array size ReDim strOldOrder(arraySize - 1) ReDim strNewOrder(arraySize - 1) For each objInstanceOrder in ColSystemOrder strOldOrder(arrayIndex) = objInstanceOrder.PartComponent arrayIndex = arrayIndex + 1 Next '*** Rearrange the array of strings with the expect order in strNewOrder array For i = 0 to (arrayIndex - 1) For j = 0 to (arrayIndex - 1) if(InStr(strOldOrder(j),"UEFI")>0) then if(InStr(strOldOrder(j),":index-"&strNewOrderInput(i))> 0) then strNewOrder(i) = strOldOrder(j) j=arrayIndex end if else if(InStr(strOldOrder(j),":"&strNewOrderInput(i))> 0) then strNewOrder(i) = strOldOrder(j) j=arrayIndex end if end if Next Next '*** Retrieve the instance of DCIM_BootConfigSetting class '*** Execute ChangeBootOrder method with corresponding parameters Set ColSystem=objWMIService.execquery ("Select * from " & strClassName) For each objInstance in ColSystem Set oInParams= objInstance.Methods_("ChangeBootOrder").InParameters.SpawnInstance_ oInParams.source = strNewOrder oInParams.AuthorizationToken = strAuthorizationToken Set returnValue = objInstance.ExecMethod_("ChangeBootOrder", oInParams) Next '*** If any errors occurred, let the user know If Err.Number <> 0 Then WScript.Echo "Set boot order failed." End If '*** Sub used to display the correct usage of the script Sub Usage() Dim strMessage strMessage = "incorrect syntax. You should run: " & vbCRLF & _ "cscript.exe /nologo SampleSetBootOrder.vbs " WScript.Echo strMessage End Sub