Lenovo ThinkStation D20 BIOS Windows Management Instrumentation Interface Depl - Page 21

Appendix A. Sample Visual Basic scripts for, configuring BIOS settings, Restore default settings

Page 21 highlights

Appendix A. Sample Visual Basic scripts for configuring BIOS settings The Visual Basic command line scripts in the ZIP file are examples that you may find helpful when configuring BIOS settings. The scripts in the ZIP file can be used as‐is on Windows XP, Windows Vista, or Windows 7 to modify BIOS settings on your Lenovo computer. T.he script can be executed on a command prompt using the cscript.exe utility. On Windows Vista and Windows 7, you must run the scripts from an administrator command prompt. Note: The scripts in this appendix are for reference only. To copy and paste scripts, use the scripts in the ZIP file. Restore default settings Use the example scripts in the ZIP file as templates to restore default settings on the local computer. Syntax: cscript.exe LoadDefaults.vbs Example: cscript.exe LoadDefaults.vbs ' ' Load default BIOS settings ' On Error Resume Next Dim colItems strComputer = "LOCALHOST" 'Change as needed Set objWMIService = GetObject("WinMgmts:" _ &"{ImpersonationLevel=Impersonate}!\\" & strComputer _ &"\root\wmi") Set colItems = objWMIService.ExecQuery("Select * from Lenovo_LoadDefaultSettings") strReturn = "error" For Each objItem in colItems ObjItem.LoadDefaultSettings ",", strReturn Next WScript.Echo " LoadDefaultSettings: " + strReturn If strReturn < > "Success" Then WScript.Quit End If Set colItems = objWMIService.ExecQuery("Select * from Lenovo_SaveBiosSettings") strReturn = "error" For Each objItem in colItems ObjItem.SaveBiosSettings ",", strReturn Next WScript.Echo " SaveBiosSettings: " + strReturn @Copyright Lenovo 2010 15

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28

@Copyright Lenovo 20
10
1
5
Appendix A. Sample Visual Basic scripts for
configuring BIOS settings
The Visual Basic command line scripts in the ZIP file are examples
that you may find helpful when configuring BIOS settings.
The scripts in the ZIP file can be used as
is on Windows XP
,
Windows Vista
,
or Windows 7
to modify BIOS
set
tings
on
your
Lenovo computer.
.
The script can
b
e executed
o
na
c
omma
nd prompt
using
the
cscript.exe utility. On
Wi
n
d
o
w
s
Vi
sta and Windows 7
,
you
must ru
n
the
scripts
from
an adm
inistrator command prompt.
Note:
The scripts in this appendix are for reference only. To copy
and paste scripts, use the scripts in the ZIP file.
Restore default settings
Use the example scripts in the ZIP file as templates to restore default
settings on the local computer.
Syntax
:
cscript.exe
LoadDefaults.vbs
Example
:
cscript.exe LoadDefaults.vbs
’ Load default BIOS settings
On Error Resume Next
Dim colItems
strComputer = “LOCALHOST”
‘Change as needed
Set
objWMIService = GetObject(“WinMgmts:” _
&"{ImpersonationLevel=Impersonate}!\\" & strComputer _
&"\root\wmi")
Set colItems = objWMIService.ExecQuery("Select * from
Lenovo_LoadDefaultSettings")
strReturn = "error"
For Each objItem in colItems
ObjItem.LoadDefaultSettings ",", strReturn
Next
WScript.Echo "
LoadDefaultSettings: " + strReturn
If strReturn < > "Success" Then
WScript.Quit
End If
Set
colItems = objWMIService.ExecQuery("Select * from
Lenovo_SaveBiosSettings")
strReturn = "error"
For
Each objItem in colItems
ObjItem.SaveBiosSettings ",", strReturn
Next
WScript.Echo "
SaveBiosSettings: " + strReturn