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")
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
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
Please log in to answer
Posted by:
cblake
13 years ago
Posted by:
darkhawktman
13 years ago
Posted by:
kchase
13 years ago
Posted by:
afzal
13 years ago
Posted by:
kchase
13 years ago
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>
<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
@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
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
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"
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
@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?
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;
Not sure what's wrong at this point. Any idea's?
Posted by:
kchase
13 years ago
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
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.
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
Posted by:
kchase
13 years ago
Posted by:
kchase
13 years ago
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
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
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.