/build/static/layout/Breadcrumb_cap_w.png

Script to update bios settings failing

I've created a a vbscript that changes the boot order in the bios on lenovo systems. Problem I'm having is if I run the script locally it works as intended, but if I create a script deployment on the kace appliance the script log shows a message of BootOrder,PCILAN:HDD0:ATAPICD0:USBFDD:USCCD:USBHDD:HDD1;
SetBiosSetting: Invalid Parameter.
I call the the script using cscript.exe BootOrder.vbs BootOrder PCILAN:HDD0:ATAPICD0:USBFDD:USCCD:USBHDD:HDD1. Below is the script I am using. Any suggestions?

'
'Set specific Bios Settings
'
On Error Resume Next
Dim colItems


If WScript.Arguments.Count <> 2 Then
WScript.Echo "BootOrder.vbs [setting] [value]"
WScript.Quit
End If

strRequest = WScript.Arguments(0) + "," + WScript.Arguments(1) + ";"

strComputer = "LOCALHOST" ' Change as needed.
Set objWMIService = GetObject("WinMgmts:" _
&"{ImpersonationLevel=Impersonate}!\\" & strComputer & "\root\wmi")
Set colItems = objWMIService.ExecQuery("Select * from

Lenovo_SetBiosSetting")

For Each objItem in colItems
ObjItem.SetBiosSetting strRequest, strReturn
Next

WScript.Echo strRequest
WScript.Echo " SetBiosSetting: " + strReturn

If strReturn <> "Success" Then
WScript.Quit
End If

Set colItems = objWMIService.ExecQuery("Select * from

Lenovo_SaveBiosSettings")

0 Comments   [ + ] Show comments

Answers (13)

Answer Summary:
For some reason my code would die if it passed over 4 items in the boot order. So to correct the issue I just changed it so it would run cscript bootorder.vbs BootOrder PCILAN:ATAPICD0:HDD0:HDD1 since I don't really care about booting usb devices
Posted by: cblake 13 years ago
Red Belt
1
Try using
cscript.exe "C:\Path to dependency location\BootOrder.vbs" BootOrder PCILAN:HDD0:ATAPICD0:USBFDD:USCCD:USBHDD:HDD1
in your BAT
Posted by: darkhawktman 13 years ago
Green Belt
0
How are you calling the script from the kbox? Are you using a bat script to start your vbscript? I know that I have several vbscripts that start via the bat script for various reasons.
Posted by: kchase 13 years ago
Senior Yellow Belt
0
Yes... I am using a bat script to call the vbscript. I'm getting a little closer by changing the script type to an online script and setting dependcies and tasks, but it still is not doing what it should.
Posted by: afzal 13 years ago
Fourth Degree Green Belt
0
you have not defined strreturn any where in the code , that is why you are getting this error , when you are trying to use as argument.
Posted by: kchase 13 years ago
Senior Yellow Belt
0
That's what I have but this is the message I keep getting. It looks like the issue is the extra "\" in the command. How do I fix this? I've tried editing it in xml but it just keeps getting put back. Below is my xml script.

<?xml version="1.0" encoding="utf-8" ?>
<kbots xmlns="http://kace.com/Kbots.xsd">
<kbot>

<config name="Change Bios Boot Order" type="policy" id="164" version="1305051576" description="Script to change the Boot order in the bios so that PCI LAN is the first boot device.">

<dependencies>
<dependency name="/packages/kbots/164/BootOrder.bat" checksum="10d51844036c268fb0be241b445ea665" />
<dependency name="/packages/kbots/164/BootOrder.vbs" checksum="a1386a742aa970f0640e70b037c1815e" />
<dependency name="/packages/kbots/164/kace2498.bat" checksum="305e9befff17bce067f8862c9fee200b" />
</dependencies>

<execute disconnected="false" logged_off="false">
</execute>

</config>

<compliance>

<verify on_failure="break" attempts="1">

<file_exists path="$(KACE_DEPENDENCY_DIR)" file="BootOrder.vbs" />

<on_verify_success>
<launch_program path="$(KACE_DEPENDENCY_DIR)" program="kace2498.bat" wait="false" parms="" />
</on_verify_success>

<on_verify_failure>

<on_remediation_success>
</on_remediation_success>

<on_remediation_failure>
</on_remediation_failure>

</on_verify_failure>

</verify>

</compliance>

</kbot>
</kbots>
Posted by: kchase 13 years ago
Senior Yellow Belt
0
@afzal... Then why on earth is it working when run locally? I am able to use this script fine on the local machine but it appears to run when deployed from the kbox and actually does nothing. I get the following when I check the script log.

Started: May 10 2011 02:21:13 PM
Finished: May 10 2011 02:21:13 PM
Elapsed Time: 0 second
Status: 1


Output Log
Running As : SYSTEM
Activity Log
Checking if file exists: C:\Program Files (x86)\KACE\KBOX\\packages\kbots\164\BootOrder.vbs
Launching program: C:\Program Files (x86)\KACE\KBOX\\packages\kbots\164\kace2498.bat
Posted by: afzal 13 years ago
Fourth Degree Green Belt
0
I wonder if you have tried to run the script using the following format, directly without using bat file. If you need some clarification please visit my blog http://afzalyousufi.blogspot.com/ and view the procedure to run VB Script . Further, I have tried the following format to pass Parameters and it is working fine for me.

a. Directory : $(KBOX_SYS_DIR)
b. File: cscript.exe
c. Wait for startup : Yes
d. Parameters: "$(KACE_DEPENDENCY_DIR)\YourVBS.vbs"

In your case it should be something like this

Parameters: "$(KACE_DEPENDENCY_DIR)\BootOrder.vbs" "BootOrder" "PCILAN:HDD0:ATAPICD0:USBFDD:USCCD:USBHDD:HDD1"
Posted by: kchase 13 years ago
Senior Yellow Belt
0
@afzal....
Thanks... That got me further, but now I get the following message.

Running As : SYSTEM
C:\Windows\system32\cscript.exe
standard output:
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.
BootOrder,HDD0:PCILAN:ATAPICD0:USBFDD:USCCD:USBHDD:HDD1;
SetBiosSetting: Invalid Parameter

Not sure what's wrong at this point. Any idea's?
Posted by: kchase 13 years ago
Senior Yellow Belt
0
ok.... I figured out my invalid parameter issue, but now I get this other message in the log. Any suggestions on what I'm doing wrong now?

Started: May 12 2011 11:46:17 AM
Finished: May 12 2011 11:46:17 AM
Elapsed Time: 0 second
Status: 1


Output Log
Running As : SYSTEM
C:\Windows\system32\cscript.exe
standard output:
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.
Input Error: There is no file extension in "C:\Program".
Activity Log
Checking if file exists: C:\Program Files (x86)\KACE\KBOX\\packages\kbots\164\BootOrder.vbs
Launching program: C:\Windows\system32\cscript.exe C:\Program Files (x86)\KACE\KBOX\\packages\kbots\164\BootOrder.vbs BootOrder HDD0:PCILAN:ATAPICD0:USBFDD:USCCD:USBHDD:HDD1
Posted by: RichB 13 years ago
Second Degree Brown Belt
0
Change this line:
Checking if file exists: C:\Program Files (x86)\KACE\KBOX\\packages\kbots\164\BootOrder.vbs

To this:
Checking if file exists: "C:\Program Files (x86)\KACE\KBOX\\packages\kbots\164\BootOrder.vbs"
Posted by: kchase 13 years ago
Senior Yellow Belt
0
Thanks for the suggestion, but that does nothing. I still get the same error. This can be pretty frustrating. I really need this to work since we have a very small IT staff and don't have the time to walk around to each machine and change the bios boot order.
Posted by: kchase 13 years ago
Senior Yellow Belt
0
Now it gets a little more interesting... I now get this message.

Running As : SYSTEM
c:\windows\system32\cscript.exe
standard output:
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.
Input Error: There is no script engine for file extension ".vbs BootOrder HDD0:PCILAN:ATAPICD0:USBFDD
Posted by: kchase 13 years ago
Senior Yellow Belt
0
Ok.. I solved the issue. For some reason my code would die if it passed over 4 items in the boot order. So to correct the issue I just changed it so it would run cscript bootorder.vbs BootOrder PCILAN:ATAPICD0:HDD0:HDD1 since I don't really care about booting usb devices.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ