Files
Infra-LAB/projects/MDT/Scripts/BIOSConfig/Lenovo/ThinkBiosConfig.hta
T

1590 lines
53 KiB
HTML

<!--
--Filename: ThinkBiosConfig.hta
--Author: Devin McDermott
--Version: 0.8
--Description: This application allows system administrators to easily edit the BIOS settings
on a local or remote computer through the command line or graphical interface.
-->
<html>
<head>
<title>Think BIOS Configurator</title>
<HTA:APPLICATION
APPLICATIONNAME="Think BIOS Configurator"
SCROLL="yes"
SINGLEINSTANCE="no"
ID="objTBCHTA"
BORDER="thin"
BORDERSTYLE="normal"
>
<style>
body {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: .8em;
}
p {
font-size: .8em;
}
.titlebar {
text-align:center;
padding: 14px;
color:white;
background-color:black;
}
.fileactions {
text-align:left;
padding:8px;
background-color:#d3d3d3;
}
.btn {
background: #3498db;
color: #ffffff;
padding: 8px;
text-decoration: none;
}
.btn:hover {
background: #3cb0fd;
text-decoration: none;
}
.file {
padding: 8px;
background: white;
}
label { font-size: .8em; }
#security {
padding:6px;
background-color:#e6e6e6;
width:100%
}
#security label {margin-left:16px;margin-right:16px;}
#security select {width:120px;}
#security_actions {
width:100%;
font-size: .9em;
}
#targeting_div {
padding:6px;
background-color:#f2f2f2;
}
.result-table {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
width: 100%;
border-collapse: collapse;
}
.result-table td {
border: 1px solid #3498db;
padding: 16px 20px 16px 20px;
}
.result-table select {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
}
</style>
</head>
<script language="VBScript">
Option Explicit
Dim gCurrentSettings : Set gCurrentSettings = CreateObject("Scripting.Dictionary")
Dim gChangedSettings : Set gChangedSettings = CreateObject("Scripting.Dictionary")
Dim gNetworkArray()
Dim objShell : Set objShell = CreateObject("WScript.Shell")
Dim myCur : myCur = objShell.CurrentDirectory
Set objShell = Nothing
Dim gTargetComputerName : gTargetComputerName = "LOCALHOST"
Dim gTargetComputerModel : gTargetComputerModel = ""
Dim gRemoteCommand : gRemoteCommand = ""
Dim gPwd : gPwd = ""
Dim gRefresh : gRefresh = False
Dim gFirstRun : gFirstRun = True
Dim gTargetDifferentComputer : gTargetDifferentComputer = False
Dim gIsALaptop : gIsALaptop = False
Dim gValueList : gValueList = ""
Dim gUsername : gUsername = ""
Dim gPassword : gPassword = ""
Dim gDifferentUser : gDifferentUser = False
Dim gCurrentDirectory
'---------------------------------------------------------
'---------------------- Main Sub -------------------------
'---------------------------------------------------------
' The main program that runs on body load of the HTA
' Dynamically fill the HTA with the WMI information
Sub TestSub
On Error Resume Next
gTargetComputerModel = UpdateComputerModel
If (gFirstRun = True) Then
getNetworkAddresses
gRefresh = True
'TestElevation
gFirstRun = False
End If
Dim colItems, StrItem, StrValue
gChangedSettings.RemoveAll
gCurrentSettings.RemoveAll
Dim objWMIService : Set objWMIService = getWMIObject("\root\wmi")
If Err = 0 Then
If(determineLocalMachine(gTargetComputerName) = True) Then
gTargetDifferentComputer = False
toggleButtonOff "localButton"
Else
gTargetDifferentComputer = True
toggleButtonOn "localButton"
End If
targeting.InnerHTML = "Accessing settings on <b><i>" & gTargetComputerName & " (" & gTargetComputerModel & ")</i></b>"
Set colItems = objWMIService.ExecQuery("Select * from Lenovo_BiosSetting")
Dim myHTML, objItem, count, color, rowSpan, bootOrderHtml
myHTML = "<table class='result-table'><thead style='font-size:.8em;font-weight:bold'><th>Setting</th><th>Value</th><th>Setting</th><th>Value</th></thead>"
count = 0
color = "#D3D3D3"
rowSpan = 1
For Each objItem in colItems
If Len(objItem.CurrentSetting) > 0 Then
StrItem = Left(ObjItem.CurrentSetting, InStr(ObjItem.CurrentSetting, ",") - 1)
gValueList = ""
If(InStr(objItem.CurrentSetting, ";") > 0) Then
StrValue = extractString(ObjItem.CurrentSetting, InStr(ObjItem.CurrentSetting, ","), InStr(ObjItem.CurrentSetting, ";") - 1)
Dim temp : temp = extractString(ObjItem.CurrentSetting, InStr(ObjItem.CurrentSetting, ";"), Len(ObjItem.CurrentSetting))
gValueList = extractString(temp, InStr(temp, ":"), InStr(temp, "]") - 1)
'msgbox temp
Else
StrValue = Mid(ObjItem.CurrentSetting, InStr(ObjItem.CurrentSetting, ",") + 1, 256)
End If
If (Not(gCurrentSettings.Exists(StrItem))) Then
gCurrentSettings.add StrItem, StrValue
If (StrItem = "BootOrder") Then
'rowSpan = 3
bootOrderHtml = "<td id='" & (StrItem & "Text") & "'>" & replaceSymbols(StrItem) & "</td>" _
& "<td colspan=2>" & CreatePicker(StrItem, StrValue, objWMIService) & "</td><td>&nbsp;</td></tr>"
Else
rowSpan = 1
If (count mod 2 = 0) Then
count = count + 1
myHTML = myHTML & "<tr bgcolor='" & color & "'><td rowspan='" & rowSpan & "' id='" & (StrItem & "Text") & "'>" & replaceSymbols(StrItem) & "</td>" _
& "<td rowspan='" & rowSpan & "'>" & CreatePicker(StrItem, StrValue, objWMIService) & "</td>"
Else
myHTML = myHTML & "<td rowspan='" & rowSpan & "' id='" & (StrItem & "Text") & "'>" & replaceSymbols(StrItem) & "</td>" _
& "<td rowspan='" & rowSpan & "'>" & CreatePicker(StrItem, StrValue, objWMIService) & "</td></tr>"
count = count + 1
If (color = "#FFFFFF") Then
color = "#D3D3D3"
Else
color = "#FFFFFF"
End If
End If
End If
End If
End If
Next
If (color = "#FFFFFF") Then
color = "#D3D3D3"
Else
color = "#FFFFFF"
End If
myHTML = myHTML & "<tr bgcolor='" & color & "'>" & bootOrderHtml
myHTML = myHTML & " <tr>" _
& "<td colspan='4'>" _
& " <center>" _
& " <input type='button' class='btn' id='saveButton' value='Save Changed Settings' name='save_button' onClick='SaveChanges'>" _
& " <input type='button' class='btn' value='Restore BIOS Defaults' name='default_button' onClick='SetDefaults'>" _
& " <input type='button' class='btn' id='resetButton' value='Reset to Current Settings' name='reset_button' onClick='ResetSub'>" _
& " </center>" _
& "</td>" _
& "</tr>"
myHTML = myHTML & "<tr><td style='border:none'>&nbsp;</td><td style='border=none'>&nbsp;</td></tr></table>"
dataArea.InnerHTML = myHTML
Else
DisplayErrorInfo
LocalSub
End If
End Sub
'---------------------------------------------------------
'-------------------- Helper subs ------------------------
'---------------------------------------------------------
Sub TestElevation(args)
Dim oShell, oExec, szStdOut
szStdOut = ""
Dim objWMIService : Set objWMIService = getWMIObject("\root\cimv2")
Dim colItems : Set colItems = objWMIService.ExecQuery("Select * From Win32_OperatingSystem")
Set objWMIService = Nothing
Dim objItem, winPE
winPE = False
For Each objItem in colItems
If (InStr(objItem.SystemDevice, "Ramdisk") > 0) Then
winPE = True
End If
Next
If (winPE <> True) Then
Set oShell = CreateObject("WScript.Shell")
Set oExec = oShell.Exec("whoami /groups")
Do While (oExec.Status = 0)
If Not oExec.StdOut.AtEndOfStream Then
szStdOut = szStdOut & oExec.StdOut.ReadAll
End if
Loop
Select Case oExec.ExitCode
Case 0
If Not oExec.StdOut.AtEndOfStream Then
szStdOut = szStdOut & oExec.StdOut.ReadAll
End If
If Instr(szStdOut,"S-1-16-12288") Then
Dim count : count = 0
Set objWMIService = getWMIObject("\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_Process WHERE Name='mshta.exe'")
For Each objItem in colItems
Dim name : name = Ubound(Split(args, "\"))
If (InStr(objItem.CommandLine, (Left(name,Len(name)-1))) > 0) Then
count = count + 1
End If
Next
If (count > 2) Then
MsgBox "Please use the other open application."
Window.close()
End If
Else
If Instr(szStdOut,"S-1-16-8192") Then
Dim shellApp : Set shellApp = CreateObject("Shell.Application")
shellApp.ShellExecute "mshta.exe", args & " uac", "", "runas", 1
'msgbox "Elevated!"
'End the non-elevated instance
Window.close()
Else
'msgbox "Unknown!"
End If
End If
Case Else
If Not oExec.StdErr.AtEndOfStream Then
msgbox oExec.StdErr.ReadAll
End If
End Select
End If
End Sub
' Finds the model that is being targeted
' Going to use this to find the correct config
Function UpdateComputerModel
Dim objWMIService : Set objWMIService = getWMIObject("\root\cimv2")
Dim colItems : Set colItems = objWMIService.ExecQuery("Select * From Win32_ComputerSystemProduct")
Set objWMIService = Nothing
Dim objItem
UpdateComputerModel = ""
For Each objItem in colItems
Dim model : model = objItem.Version
Dim longname : longname = ""
Dim word
If(InStr(model, " ")) Then
longname = Split(model, " ")
If (InStr(model, "ThinkPad")) Then
gIsALaptop = True
Else
gIsALaptop = False
End If
For Each word in longname
If (word <> "ThinkPad" And word <> "ThinkCentre" And word <> "ThinkStation" And word <> "S1") Then
UpdateComputerModel = UpdateComputerModel & word
End If
Next
Else
UpdateComputerModel = model
End If
Next
End Function
' See what file has been be picked by the user.
' Toggle buttons accordingly
Sub CheckFile
If (InStr(file.value, ".") > 0) Then
If (LCase(Mid(file.value, InStrRev(file.value, "."))) = ".ini") Then
toggleButtonOn "configButton"
End If
Else
toggleButtonOff "configButton"
End If
End Sub
' Apply the configuration file that was selected
Sub ApplyFile
If(file.value <> "") Then
If(doValidationSave) Then
ParseFile file.value, gPwd
TestSub
End If
End If
End Sub
'Creates a WMI object with the specified namespace
'Different ways are needed if the user provides a username and password
Function getWMIObject(namespace)
If(gUsername = "" Or gPassword = "") Then
Set getWMIObject=GetObject("WinMgmts:" _
& "{ImpersonationLevel=Impersonate" & gRemoteCommand &"}!" _
& "\\" & gTargetComputerName & namespace)
Else
Dim objSWbemLocator : Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Dim objSWbemServices : Set objSWbemServices = objSWbemLocator.ConnectServer(gTargetComputerName, namespace, gUsername, gPassword)
'6 = pktPrivacy
objSWbemServices.Security_.AuthenticationLevel = 6
Set getWMIObject=objSWbemServices
End If
End Function
' Adds a key-value pair to the gChangedSettings dictionary
' If there isnt a key already just add the pair
' If there is a key update it
' Color the setting if it is being changed from the current value
Sub addToChanges(key)
Dim o
For Each o In Document.getElementById(key).Options
If o.Selected Then
If(gChangedSettings.Exists(key)) Then
gChangedSettings(key) = o.Text
If(gCurrentSettings(key) = o.Text) Then
gChangedSettings.remove(key)
changeColor (key & "Text"), "black"
Else
changeColor (key & "Text"), "red"
End If
Else
gChangedSettings.add key, o.Text
changeColor (key & "Text"), "red"
End If
End If
Next
End Sub
'Clears out all the changed settings and reselects the current settings on the computer
Sub ResetSub
Dim key, o
For Each key in gChangedSettings
gChangedSettings.Remove(key)
If (InStr (key, "Boot Sequence") > 0 Or key = "BootOrder") Then
resetBootLists key, gCurrentSettings(key)
Else
For Each o in Document.getElementById(key).Options
If (o.Text = gCurrentSettings(key)) Then
o.selected = True
End If
Next
End If
changeColor(key & "Text"), "black"
Next
End Sub
'Adds the newly created boot order to the changes dictionary
'Made it a function so JavaScript can call it
Function addToChangesBootList(idOfSelect)
Dim value : value = generateBootList(idOfSelect)
Dim key : key = extractKey(idOfSelect)
If(gChangedSettings.Exists(key)) Then
gChangedSettings(key) = value
If(gCurrentSettings(key) = value) Then
gChangedSettings.remove(key)
changeColor (key & "Text"), "black"
Else
changeColor (key & "Text"), "red"
End If
Else
gChangedSettings.add key, value
changeColor (key & "Text"), "red"
End If
End Function
'---------------------------------------------------------
'--------------------- HTML subs -------------------------
'---------------------------------------------------------
' Creates a dropdown menu for the setting based off the WMI queries
' Also sets the selected value to the current setting on the target machine
Function CreatePicker(key, value, objWMIService)
Dim htmlForDropdown, values, val, parsedValue
val = ""
parsedValue = ""
values = ""
If (InStr(key, "Alarm Time") > 0 Or InStr(key, "Alarm Date") > 0) Then
htmlForDropdown = value
ElseIf(gIsALaptop = True) Then
Dim selItems, objItem2, strSelection
Set selItems = objWMIService.ExecQuery("Select * from Lenovo_GetBiosSelections")
For Each objItem2 in selItems
objItem2.GetBiosSelections key + ";", strSelection
Next
values = Split(strSelection, ",")
If(key = "BootOrder") Then
parsedValue = Split(value, ":")
htmlForDropdown = createBootOptionChoice(key, parsedValue, value)
htmlForDropdown = htmlForDropdown & "<td><select id='" & key & "right' size='4'>"
For Each val in values
If (InStr(value, val) = 0) Then
htmlForDropdown = htmlForDropdown & "<option value='" & val &"'>" & val & "</option>"
End If
Next
htmlForDropdown = htmlForDropdown & "</select></td></tr></table>"
Else
htmlForDropdown = "<select style='width:175px' id='" & key _
& "' onChange='addToChanges(" & chr(34) & key & chr(34) & ")'>"
For Each val in values
htmlForDropdown = htmlForDropdown & "<option value='" & val & "'"
If (StrComp(val,value) = 0) Then
htmlForDropdown = htmlForDropdown & " selected"
End If
htmlForDropdown = htmlForDropdown & ">" & val & "</option>"
Next
htmlForDropdown = htmlForDropdown & "</select>"
End If
Else
If (InStr (key, "Boot Sequence") > 0) Then
parsedValue = Split(value, ":")
values = Split(gValueList, ":")
htmlForDropdown = createBootOptionChoice(key, parsedValue, value)
htmlForDropdown = htmlForDropdown & "<td><select id='" & key & "right' size='4'>"
For Each val in values
If (InStr(val, "Excluded") = 0) Then
htmlForDropdown = htmlForDropdown & "<option value='" & val &"'>" & val & "</option>"
End If
Next
htmlForDropdown = htmlForDropdown & "</select></td></tr></table>"
Else
values = Split(gValueList, ",")
htmlForDropdown = "<select style='width:175px' id='" & key _
& "' onChange='addToChanges(" & chr(34) & key & chr(34) & ")'>"
For Each val in values
htmlForDropdown = htmlForDropdown & "<option value='" & val & "'"
If (StrComp(val,value) = 0) Then
htmlForDropdown = htmlForDropdown & " selected"
End If
htmlForDropdown = htmlForDropdown & ">" & val & "</option>"
Next
htmlForDropdown = htmlForDropdown & "</select>"
End If
End If
CreatePicker=htmlForDropdown
End Function
' Method to reuse the code of creating the boot order changers
' Returns a bunch of HTML code
Function createBootOptionChoice(key, currentSettings, value)
Dim result : result = ""
Dim val
result = result & "<p align='center'>Current setting: " & value & "</p>"
result = result & "<table width='100%'><thead style='font-size:.7em;'><th>Boot Order</th><th>&nbsp;</th><th>Options</th></thead><tr><td>"
result = result & "<select id='" & key & "bootList' size='4' width='80px'>"
For Each val in currentSettings
result = result & "<option value='"& val &"'>" & val & "</option>"
Next
result = result & "</select></td>"
result = result & "<td align='center' padding='8px'><input type='button' value='Up' style='font-size:.7em;width:80px' onclick='moveUp(" & chr(34) & key & "bootList"& chr(34) &")'><br>" _
& "<input type='button' value='Down' style='font-size:.7em;width:80px' onclick='moveDown(" & chr(34) & key & "bootList"& chr(34) &")'><br>" _
& "<br><input style='font-size:.7em;' onclick='swapElement "& chr(34) & key & "right"& chr(34) &","& chr(34) & key & "bootList"& chr(34) &"' type='button' value='&nbsp;<<&nbsp;'>" _
& "&nbsp;&nbsp;<input style='font-size:.7em;' onclick='swapElement "& chr(34) & key & "bootList"& chr(34) &","& chr(34) & key & "right"& chr(34) &"' type='button' value='&nbsp;>>&nbsp;'></td>"
createBootOptionChoice=result
End Function
' Display a secondary menu if the user says there is a supervisor password on the target machine
' Creates a space for the password, encrypting key, encoding type and language
Sub ShowPasswordInfoSub
Dim passwordHTML : passwordHTML = ""
If (supervisor.Checked = True) Then
passwordHTML = passwordHTML & "<table id='passwordtable'><tr><td><label for='passEncode'>Encoding:</label>" _
& "<select id='passEncode'><option value='ascii'>ascii</option>" _
& "<option value='scancode'>scancode</option></select></td>" _
& "<td><label for='passBox' " _
& "title='Your supervisor password'>Enter password:</label>" _
& "<input type='password' id='passBox'></td></tr>" _
& "<tr><td><label for='passLang'>Language:</label>" _
& "<select id='passLang'><option value='us'>us</option>" _
& "<option value='fr'>fr</option>" _
& "<option value='gr'>gr</option></select></td>" _
& "<td><label for='passEncrypt' " _
& "title='Used for exporting settings with supervisor password.'>Enter encrypting key:</label>" _
& "<input type='textbox' id='passEncrypt' value='" & makeid() & "'></td></tr></table>"
Else
passwordHTML = ""
End If
passwordStuff.innerHTML = passwordHTML
End Sub
' Display a secondary menu if the user says there is a supervisor password on the target machine
' Creates a space for the password, encrypting key, encoding type and language
Sub ShowUserInfoSub
Dim userHTML : userHTML = ""
If (user.Checked = True) Then
userHTML = userHTML & "<table id='usertable'><tr>" _
& "<td><label for='username' title='Username you wish to connect with.'>Enter username:</label>" _
& "<input type='textbox' id='uNameBox'></td></tr>" _
& "<td><label for='uPassBox' title='The password for that username password'>Enter password:</label>" _
& "<input type='password' id='uPassBox'></td></tr>" _
& "<tr><td><label>Add <em>yourDomain\</em> if needed to the username</label></td></tr></table>"
Else
userHTML = ""
End If
userStuff.innerHTML = userHTML
End Sub
'---------------------------------------------------------
'--------------------- Input subs ------------------------
'---------------------------------------------------------
' Restore the default settings for the targeted machine
Sub SetDefaults
Dim a : a = MsgBox("Are you sure you want to restore the default settings?",1,"Warning")
If(a = 1) Then
Dim colItems, strReturn, objItem
Dim objWMIService : Set objWMIService = getWMIObject("\root\wmi")
Set colItems = objWMIService.ExecQuery("Select * from Lenovo_LoadDefaultSettings")
strReturn = "error"
For Each objItem in colItems
ObjItem.LoadDefaultSettings ";", strReturn
Next
If(strReturn = "Success") Then
Set colItems = objWMIService.ExecQuery("Select * from Lenovo_SaveBiosSettings")
strReturn = "error"
For Each objItem in colItems
ObjItem.SaveBiosSettings ";", strReturn
Next
Set objWMIService = Nothing
TestSub
End If
End If
End Sub
' Save the pending changes to the targeted machine
Sub SaveChanges()
If (doValidationSave) Then
Dim colItems, objFSO, objItem, strRequest, resultString, strReturn, key
resultString = ""
Dim objWMIService : Set objWMIService = getWMIObject("\root\wmi")
If(gChangedSettings.Count > 0) Then
For Each key In gChangedSettings
Set colItems = objWMIService.ExecQuery("Select * from Lenovo_SetBiosSetting")
strRequest = key + "," + gChangedSettings(key)
If(gPwd <> "") Then
strRequest = strRequest + "," + gPwd
End If
strRequest = strRequest + ";"
For Each objItem in colItems
ObjItem.SetBiosSetting strRequest, strReturn
Next
If(strReturn = "Success") Then
Set colItems = objWMIService.ExecQuery("Select * from Lenovo_SaveBiosSettings")
strReturn = "error"
For Each objItem in colItems
ObjItem.SaveBiosSettings gPwd & ";", strReturn
Next
resultString = resultString & "Saving " & key & ": " & strReturn & vbCrLf
Else
resultString = resultString & "Setting " & key & " to " & gChangedSettings(key) & ": " & strReturn & vbCrLf
End If
Next
gPwd = ""
If (gRefresh = True) Then
msgbox resultString & vbCrLf & vbCrLf & "Any successful settings will be applied at next reboot."
If (supervisor.Checked = True) Then
passBox.value = ""
End If
TestSub
End If
Else
MsgBox "No changes found"
End If
End If
End Sub
' Save the current and pending changes to a config file
' If the supervisor box is checked then encrypt the password along with encoding and language
Sub ExportChanges
If(doValidationExport) Then
Dim colItems, objFSO, outfile, objFile, key
Set objFSO=CreateObject("Scripting.FileSystemObject")
outFile = gCurrentDirectory & gTargetComputerModel & "Config.ini"
Set objFile = objFSO.CreateTextFile(outFile,True)
If (supervisor.Checked = True) Then
objFile.Write EncryptValue(gPwd, passEncrypt.Value) & vbCrLf
gPwd = ""
passBox.value = ""
End If
For Each key In gCurrentSettings
If(gChangedSettings.Exists(key)) Then
objFile.Write key & "," & gChangedSettings(key) & vbCrLf
Else
objFile.Write key & "," & gCurrentSettings(key) & vbCrLf
End If
Next
objFile.Close
Set objFile = Nothing
End If
End Sub
'---------------------------------------------------------
'--------------- Validation Functions --------------------
'---------------------------------------------------------
' Make sure the proper info is populated if a export is attempted
Function doValidationExport()
If (supervisor.Checked = True) Then
If (Len(passBox.value) = 0) Then
MsgBox "Supervisor password."
passBox.focus
doValidationExport = False
ElseIf (Len(passEncrypt.value) = 0) Then
MsgBox "A key phrase."
passEncrypt.focus
doValidationExport = False
Else
If Not isAlphaNumeric(passEncrypt.value) Then
MsgBox "Invalid Characters."
passEncrypt.focus
doValidationExport = False
Else
doValidationExport = True
gPwd = passBox.Value & "," & passEncode.Value & "," & passLang.Value
End If
End If
Else
doValidationExport = True
End If
End Function
' Make sure the proper info is populated if a save is attempted
Function doValidationSave()
If (supervisor.Checked = True) Then
If (Len(passBox.value) = 0) Then
MsgBox "Supervisor password."
passBox.focus
doValidationSave = False
Else
doValidationSave = True
gPwd = passBox.Value & "," & passEncode.Value & "," & passLang.Value
End If
Else
doValidationSave = True
End If
End Function
'---------------------------------------------------------
'------------------- Targeting subs ----------------------
'---------------------------------------------------------
' Gathers a list of the all the references to the local machine
' Info is stored in an array
Sub getNetworkAddresses
Dim intSize, objWMIService, colItems, objItem
intSize = 1
ReDim Preserve gNetworkArray(intSize)
gNetworkArray(0) = "LOCALHOST"
Set objWMIService = getWMIObject("\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
For Each objItem in colItems
gNetworkArray(intSize) = objItem.Name
intSize = intSize + 1
Next
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled=True")
For Each objItem in colItems
If Not IsNull(objItem.IPAddress(0)) Then
ReDim Preserve gNetworkArray(intSize)
gNetworkArray(intSize) = objItem.IPAddress(0)
intSize = intSize + 1
End If
Next
End Sub
' Checks to see if the address being targeted is actually the local machine
Function determineLocalMachine(computerAddress)
Dim local : local = false
Dim i
For i = 0 to Ubound(gNetworkArray)
If gNetworkArray(i) = UCase(computerAddress) then
local = true
End If
Next
determineLocalMachine=local
End Function
' Prompt the user for a hostname or ip that they want to access
Sub RemoteSub
Dim strMessage : strMessage = InputBox("Enter the IP address or hostname for the computer you wish to access remotely:", "Target Remote Computer")
If strMessage <> "" Then
If(Reachable(strMessage) = True) Then
gTargetComputerName = strMessage
gRemoteCommand = ",authenticationLevel=pktPrivacy"
If(user.checked = True) Then
gUsername = uNameBox.value
gPassword = uPassBox.value
uPassBox.value = ""
uNameBox.value = ""
user.checked = False
ShowUserInfoSub
Else
gUsername = ""
gPassword = ""
End If
gChangedSettings.RemoveAll
gCurrentSettings.RemoveAll
TestSub
Else
MsgBox "Host is unreachable"
End If
End If
End Sub
'Uses the WMI PingStatus object to determine if a host is reachable
Function Reachable(strComputer)
Dim wmiQuery, objWMIService, objPing, objStatus
wmiQuery = "Select * From Win32_PingStatus Where Address = '" & strComputer & "'"
Set objWMIService = getWMIObject("\root\cimv2")
Set objPing = objWMIService.ExecQuery(wmiQuery)
For Each objStatus in objPing
If IsNull(objStatus.StatusCode) Or objStatus.Statuscode<>0 Then
Reachable = False 'if computer is unreachable, return false
Else
Reachable = True 'if computer is reachable, return true
End If
Next
End Function
' Used by the 'Target local' button to bring the user back to the local machine settings.
Sub LocalSub
gTargetComputerName = "LOCALHOST"
gRemoteCommand = ""
gChangedSettings.RemoveAll
gCurrentSettings.RemoveAll
gUsername = ""
gPassword = ""
TestSub
End Sub
'---------------------------------------------------------
'------------------ Commandline subs ---------------------
'---------------------------------------------------------
' Reads an exported configuration file
' Compare this to the current settings on the computer and apply the difference
Sub ParseFile(filename, passKey)
Dim objFileToRead : Set objFileToRead=CreateObject("Scripting.FileSystemObject")
If (InStr(filename, ":") = 0) Then
filename = gCurrentDirectory & filename
End If
If (objFileToRead.FileExists(filename)) Then
Dim encrypted, strLine, keyValue
Set objFileToRead=CreateObject("Scripting.FileSystemObject").OpenTextFile(filename,1)
If (passKey <> "" And gRefresh = False) Then
encrypted = objFileToRead.ReadLine
If (InStr(encrypted, ",") > 0) Then
If(InStr(passKey, ",") > 0) Then
gPwd = passKey
Else
gPwd = passKey & ",ascii,us"
End If
keyValue = Split(encrypted, ",")
If(gCurrentSettings.Exists(keyValue(0)) And gCurrentSettings(keyValue(0)) <> keyValue(1)) Then
gChangedSettings.add keyValue(0), keyValue(1)
End If
Else
gPwd = DecryptValue(encrypted, passKey)
End If
End If
do while not objFileToRead.AtEndOfStream
strLine = objFileToRead.ReadLine()
If (InStr(strLine, ",") > 0) Then
keyValue = Split(strLine, ",")
If(gCurrentSettings.Exists(keyValue(0)) And gCurrentSettings(keyValue(0)) <> keyValue(1)) Then
gChangedSettings.add keyValue(0), keyValue(1)
End If
End If
loop
objFileToRead.Close
Set objFileToRead = Nothing
SaveChanges
End If
End Sub
' Used to make a single change
' keyValue is of the form "key,value"
Sub MakeSingleChange(setting, passKey)
If (passKey <> "") Then
If(InStr(passKey, ",") > 0) Then
gPwd = passKey
Else
gPwd = passKey & ",ascii,us"
End If
End If
Dim keyValue : keyValue = Split(setting, ",")
gChangedSettings.add keyValue(0), keyValue(1)
SaveChanges
End Sub
' Fill the current settings dictionary
' This is used for the command line features
Sub QuickFill
Dim objWMIService, colItems, objItem, StrItem, StrValue
Set objWMIService = getWMIObject("\root\wmi")
Set colItems = objWMIService.ExecQuery("Select * from Lenovo_BiosSetting")
Set objWMIService = Nothing
For Each objItem in colItems
If Len(objItem.CurrentSetting) > 0 Then
StrItem = Left(ObjItem.CurrentSetting, InStr(ObjItem.CurrentSetting, ",") - 1)
If(InStr(objItem.CurrentSetting, ";") > 0) Then
StrValue = extractString(ObjItem.CurrentSetting, InStr(ObjItem.CurrentSetting, ","), InStr(ObjItem.CurrentSetting, ";") - 1)
Else
StrValue = Mid(ObjItem.CurrentSetting, InStr(ObjItem.CurrentSetting, ",") + 1, 256)
End If
gCurrentSettings.add StrItem, StrValue
End If
Next
End Sub
'---------------------------------------------------------
'------------------ Encryption subs ----------------------
'---------------------------------------------------------
' Decrypt some cipher text using a specified passphrase
Function DecryptValue(cipherText, key)
DecryptValue=Tea.decrypt(cipherText, key)
End Function
' Encrypt a string using a specified passphrase
Function EncryptValue(plainText, key)
EncryptValue=Tea.encrypt(plainText, key)
End Function
'---------------------------------------------------------
'-------------- Automatically called subs ----------------
'---------------------------------------------------------
'Prints the current error in a message box that the user can refer to
Sub DisplayErrorInfo
MsgBox "Error: : " & Err & vbCrLf & "Error (hex) : &H" & Hex(Err) & vbCrLf & _
"Source : " & Err.Source & vbCrLf & "Description : " & Err.Description
Err.Clear
End Sub
' Message box to warn user that there were unsaved changes
Sub checkForPendingChanges
If (gChangedSettings.Count <> 0 And gRefresh = True) Then
MsgBox "There were pending changes which were not saved"
End If
End Sub
' Dynamically set the window size based on the current resolution
Sub SetWindowSize
window.resizeTo screen.availWidth * .70, screen.availHeight * .90
window.moveTo 0, 0
End Sub
' Sub to run on the execution of the program.
' Checks for command line parameters and processes them
' Parameters are encased with quotes
' file - A file with comma separated values to be applied to the system
' config - A comma separated key-value pair to be applied to the system
' pass/key - Either the supervisor password in the case of config or the keyphrase for encryption for the config file
' help - Will display a help window
' remote - Target a different computer using the command line options
Sub Window_onLoad
Dim passKey : passKey = ""
Dim fileLocation : fileLocation = ""
Dim configSetting : configSetting = ""
Dim encrypted : encrypted = ""
Dim arrCommands, breakdown, i
' Parse the command line parameters
' Split on quotes so read every other line
' Every even index is a blank space
' chr(34) = "
TestElevation(objTBCHTA.commandLine)
arrCommands = Split(objTBCHTA.commandLine, chr(34))
gCurrentDirectory = extractString(arrCommands(1), 0, InStrRev(arrCommands(1), "\"))
For i = 3 to (Ubound(arrCommands) - 1) Step 2
breakdown = Split(arrCommands(i), "=")
Select Case LCase(breakdown(0))
Case "pass"
passKey = breakdown(1)
Case "key"
passKey = breakdown(1)
Case "file"
fileLocation = breakdown(1)
Case "config"
configSetting = breakdown(1)
Case "help"
MsgBox "Enter help"
Case "remote"
gTargetComputerName = breakdown(1)
gRemoteCommand = ",authenticationLevel=pktPrivacy"
End Select
Next
If(fileLocation <> "") Then
QuickFill
ParseFile fileLocation, passKey
Window.close()
ElseIf (configSetting <> "") Then
MakeSingleChange configSetting, passKey
Window.close()
Else
SetWindowSize
TestSub
End If
End Sub
</script>
<script language="JavaScript" type="text/javascript">
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* Block TEA (xxtea) Tiny Encryption Algorithm implementation in JavaScript */
/* (c) Chris Veness 2002-2012: www.movable-type.co.uk/tea-block.html */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* Algorithm: David Wheeler & Roger Needham, Cambridge University Computer Lab */
/* http://www.cl.cam.ac.uk/ftp/papers/djw-rmn/djw-rmn-tea.html (1994) */
/* http://www.cl.cam.ac.uk/ftp/users/djw3/xtea.ps (1997) */
/* http://www.cl.cam.ac.uk/ftp/users/djw3/xxtea.ps (1998) */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
var Tea = {}; // Tea namespace
/*
* encrypt text using Corrected Block TEA (xxtea) algorithm
*
* @param {string} plaintext String to be encrypted (multi-byte safe)
* @param {string} password Password to be used for encryption (1st 16 chars)
* @returns {string} encrypted text
*/
Tea.encrypt = function(plaintext, password) {
if (plaintext.length == 0) return (''); // nothing to encrypt
// convert string to array of longs after converting any multi-byte chars to UTF-8
var v = Tea.strToLongs(Utf8.encode(plaintext));
if (v.length <= 1) v[1] = 0; // algorithm doesn't work for n<2 so fudge by adding a null
// simply convert first 16 chars of password as key
var k = Tea.strToLongs(Utf8.encode(password).slice(0, 16));
var n = v.length;
// ---- <TEA coding> ----
var z = v[n - 1],
y = v[0],
delta = 0x9E3779B9;
var mx, e, q = Math.floor(6 + 52 / n),
sum = 0;
while (q-- > 0) { // 6 + 52/n operations gives between 6 & 32 mixes on each word
sum += delta;
e = sum >>> 2 & 3;
for (var p = 0; p < n; p++) {
y = v[(p + 1) % n];
mx = (z >>> 5 ^ y << 2) + (y >>> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z);
z = v[p] += mx;
}
}
// ---- </TEA> ----
var ciphertext = Tea.longsToStr(v);
return Base64.encode(ciphertext);
}
/*
* decrypt text using Corrected Block TEA (xxtea) algorithm
*
* @param {string} ciphertext String to be decrypted
* @param {string} password Password to be used for decryption (1st 16 chars)
* @returns {string} decrypted text
*/
Tea.decrypt = function(ciphertext, password) {
if (ciphertext.length == 0) return ('');
var v = Tea.strToLongs(Base64.decode(ciphertext));
var k = Tea.strToLongs(Utf8.encode(password).slice(0, 16));
var n = v.length;
// ---- <TEA decoding> ----
var z = v[n - 1],
y = v[0],
delta = 0x9E3779B9;
var mx, e, q = Math.floor(6 + 52 / n),
sum = q * delta;
while (sum != 0) {
e = sum >>> 2 & 3;
for (var p = n - 1; p >= 0; p--) {
z = v[p > 0 ? p - 1 : n - 1];
mx = (z >>> 5 ^ y << 2) + (y >>> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z);
y = v[p] -= mx;
}
sum -= delta;
}
// ---- </TEA> ----
var plaintext = Tea.longsToStr(v);
// strip trailing null chars resulting from filling 4-char blocks:
plaintext = plaintext.replace(/\0+$/, '');
return Utf8.decode(plaintext);
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
// supporting functions
Tea.strToLongs = function(s) { // convert string to array of longs, each containing 4 chars
// note chars must be within ISO-8859-1 (with Unicode code-point < 256) to fit 4/long
var l = new Array(Math.ceil(s.length / 4));
for (var i = 0; i < l.length; i++) {
// note little-endian encoding - endianness is irrelevant as long as
// it is the same in longsToStr()
l[i] = s.charCodeAt(i * 4) + (s.charCodeAt(i * 4 + 1) << 8) + (s.charCodeAt(i * 4 + 2) << 16) + (s.charCodeAt(i * 4 + 3) << 24);
}
return l; // note running off the end of the string generates nulls since
} // bitwise operators treat NaN as 0
Tea.longsToStr = function(l) { // convert array of longs back to string
var a = new Array(l.length);
for (var i = 0; i < l.length; i++) {
a[i] = String.fromCharCode(l[i] & 0xFF, l[i] >>> 8 & 0xFF, l[i] >>> 16 & 0xFF, l[i] >>> 24 & 0xFF);
}
return a.join(''); // use Array.join() rather than repeated string appends for efficiency in IE
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* Base64 class: Base 64 encoding / decoding (c) Chris Veness 2002-2012 */
/* note: depends on Utf8 class */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
var Base64 = {}; // Base64 namespace
Base64.code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
/**
* Encode string into Base64, as defined by RFC 4648 [http://tools.ietf.org/html/rfc4648]
* (instance method extending String object). As per RFC 4648, no newlines are added.
*
* @param {String} str The string to be encoded as base-64
* @param {Boolean} [utf8encode=false] Flag to indicate whether str is Unicode string to be encoded
* to UTF8 before conversion to base64; otherwise string is assumed to be 8-bit characters
* @returns {String} Base64-encoded string
*/
Base64.encode = function(str, utf8encode) { // http://tools.ietf.org/html/rfc4648
utf8encode = (typeof utf8encode == 'undefined') ? false : utf8encode;
var o1, o2, o3, bits, h1, h2, h3, h4, e = [],
pad = '',
c, plain, coded;
var b64 = Base64.code;
plain = utf8encode ? Utf8.encode(str) : str;
c = plain.length % 3; // pad string to length of multiple of 3
if (c > 0) {
while (c++ < 3) {
pad += '=';
plain += '\0';
}
}
// note: doing padding here saves us doing special-case packing for trailing 1 or 2 chars
for (c = 0; c < plain.length; c += 3) { // pack three octets into four hexets
o1 = plain.charCodeAt(c);
o2 = plain.charCodeAt(c + 1);
o3 = plain.charCodeAt(c + 2);
bits = o1 << 16 | o2 << 8 | o3;
h1 = bits >> 18 & 0x3f;
h2 = bits >> 12 & 0x3f;
h3 = bits >> 6 & 0x3f;
h4 = bits & 0x3f;
// use hextets to index into code string
e[c / 3] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
}
coded = e.join(''); // join() is far faster than repeated string concatenation in IE
// replace 'A's from padded nulls with '='s
coded = coded.slice(0, coded.length - pad.length) + pad;
return coded;
}
/**
* Decode string from Base64, as defined by RFC 4648 [http://tools.ietf.org/html/rfc4648]
* (instance method extending String object). As per RFC 4648, newlines are not catered for.
*
* @param {String} str The string to be decoded from base-64
* @param {Boolean} [utf8decode=false] Flag to indicate whether str is Unicode string to be decoded
* from UTF8 after conversion from base64
* @returns {String} decoded string
*/
Base64.decode = function(str, utf8decode) {
utf8decode = (typeof utf8decode == 'undefined') ? false : utf8decode;
var o1, o2, o3, h1, h2, h3, h4, bits, d = [],
plain, coded;
var b64 = Base64.code;
coded = utf8decode ? Utf8.decode(str) : str;
for (var c = 0; c < coded.length; c += 4) { // unpack four hexets into three octets
h1 = b64.indexOf(coded.charAt(c));
h2 = b64.indexOf(coded.charAt(c + 1));
h3 = b64.indexOf(coded.charAt(c + 2));
h4 = b64.indexOf(coded.charAt(c + 3));
bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
o1 = bits >>> 16 & 0xff;
o2 = bits >>> 8 & 0xff;
o3 = bits & 0xff;
d[c / 4] = String.fromCharCode(o1, o2, o3);
// check for padding
if (h4 == 0x40) d[c / 4] = String.fromCharCode(o1, o2);
if (h3 == 0x40) d[c / 4] = String.fromCharCode(o1);
}
plain = d.join(''); // join() is far faster than repeated string concatenation in IE
return utf8decode ? Utf8.decode(plain) : plain;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* Utf8 class: encode / decode between multi-byte Unicode characters and UTF-8 multiple */
/* single-byte character encoding (c) Chris Veness 2002-2012 */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
var Utf8 = {}; // Utf8 namespace
/**
* Encode multi-byte Unicode string into utf-8 multiple single-byte characters
* (BMP / basic multilingual plane only)
*
* Chars in range U+0080 - U+07FF are encoded in 2 chars, U+0800 - U+FFFF in 3 chars
*
* @param {String} strUni Unicode string to be encoded as UTF-8
* @returns {String} encoded string
*/
Utf8.encode = function(strUni) {
// use regular expressions & String.replace callback function for better efficiency
// than procedural approaches
var strUtf = strUni.replace(/[\u0080-\u07ff]/g, // U+0080 - U+07FF => 2 bytes 110yyyyy, 10zzzzzz
function(c) {
var cc = c.charCodeAt(0);
return String.fromCharCode(0xc0 | cc >> 6, 0x80 | cc & 0x3f);
});
strUtf = strUtf.replace(/[\u0800-\uffff]/g, // U+0800 - U+FFFF => 3 bytes 1110xxxx, 10yyyyyy, 10zzzzzz
function(c) {
var cc = c.charCodeAt(0);
return String.fromCharCode(0xe0 | cc >> 12, 0x80 | cc >> 6 & 0x3F, 0x80 | cc & 0x3f);
});
return strUtf;
}
/**
* Decode utf-8 encoded string back into multi-byte Unicode characters
*
* @param {String} strUtf UTF-8 string to be decoded back to Unicode
* @returns {String} decoded string
*/
Utf8.decode = function(strUtf) {
// note: decode 3-byte chars first as decoded 2-byte strings could appear to be 3-byte char!
var strUni = strUtf.replace(/[\u00e0-\u00ef][\u0080-\u00bf][\u0080-\u00bf]/g, // 3-byte chars
function(c) { // (note parentheses for precedence)
var cc = ((c.charCodeAt(0) & 0x0f) << 12) | ((c.charCodeAt(1) & 0x3f) << 6) | (c.charCodeAt(2) & 0x3f);
return String.fromCharCode(cc);
});
strUni = strUni.replace(/[\u00c0-\u00df][\u0080-\u00bf]/g, // 2-byte chars
function(c) { // (note parentheses for precedence)
var cc = (c.charCodeAt(0) & 0x1f) << 6 | c.charCodeAt(1) & 0x3f;
return String.fromCharCode(cc);
});
return strUni;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/**
* Supplies the user with a randomly generated 16 character string
*
* @returns {String} 16 character encrypting key
*/
function makeid()
{
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for( var i=0; i < 16; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}//end makeid
/**
* Changes the color of a specified element
*
* @param {String} id The string id of the element to be changed
* @param {String} color The string representation of a color
*/
function changeColor(id, color)
{
document.getElementById(id).style.color = color;
}//end changeColor
/**
* Turns a button on for use
*
* @param {String} id The string id of the button to be enabled
*/
function toggleButtonOn(id)
{
document.getElementById(id).disabled = false;
}//end toggleButtonOn
/**
* Turns a button off
*
* @param {String} id The string id of the button to be disabled
*/
function toggleButtonOff(id)
{
document.getElementById(id).disabled = true;
}//end toggleButtonOff
/**
* VBScript lacks a substring method
* This makes parsing much easier
*
* @param {String} str The string which a section is to be extracted from
* @param {String} start The beginning index
* @param {String} end The end index
* @returns {String} The substring of the original string
*/
function extractString (str, start, end)
{
return str.substring(start, end);
}//end extractString
/**
* Get the key of the boot option from the select id
* "bootList" is cut off
*
* @param {String} selectId The id of the select
*/
function extractKey (selectId)
{
return selectId.slice(0,-8);
}//end extractKey
/**
* Get the key of the boot option from the select id
* "bootList" is cut off
*
* @param {String} selectId The id of the select
*/
function removeUACTag (str)
{
return str.slice(0,-4);
}//end extractKey
/**
* Swaps elements from two different select lists
* Boot list is not allowed to be emptied
*
* @param {String} fromList The list the object is coming from
* @param {String} toList The list the object is moving to
*/
function swapElement(fromList,toList)
{
var selectOptions = document.getElementById(fromList);
for (var i = 0; i < selectOptions.length; i++)
{
var opt = selectOptions[i];
if (opt.selected && ((selectOptions.length > 1 && fromList.indexOf("bootList") > -1) || fromList.indexOf("right") > -1))
{
document.getElementById(fromList).removeChild(opt);
document.getElementById(toList).appendChild(opt);
i--;
}//end if
}//end for
//figure out which is bootlist
if(~fromList.indexOf("bootList"))
addToChangesBootList(fromList);
else
addToChangesBootList(toList);
}//end swapElement
/**
* Moves the selected item up in the boot list
*
* @param {String} selectId The id of the select being modified
*/
function moveUp(selectId)
{
var selectList = document.getElementById(selectId);
var selectOptions = selectList.getElementsByTagName('option');
for (var i = 1; i < selectOptions.length; i++)
{
var opt = selectOptions[i];
if (opt.selected)
{
selectList.removeChild(opt);
selectList.insertBefore(opt, selectOptions[i - 1]);
}//end if
}//end for
addToChangesBootList(selectId);
}//end moveUp
/**
* Moves the selected item down in the boot list
*
* @param {String} selectId The id of the select being modified
*/
function moveDown(selectId) {
var selectList = document.getElementById(selectId);
var selectOptions = selectList.getElementsByTagName('option');
for (var i = selectOptions.length - 2; i >= 0; i--)
{
var opt = selectOptions[i];
if (opt.selected)
{
var nextOpt = selectOptions[i + 1];
opt = selectList.removeChild(opt);
nextOpt = selectList.replaceChild(opt, nextOpt);
selectList.insertBefore(nextOpt, opt);
}//end if
}//end for
addToChangesBootList(selectId);
}//end moveDown
/**
* Function to create the colon separated string needed for the boot order key
*
* @param {String} id The id of the select element that needs to be converted
* @returns {String} The colon separated value
*/
function generateBootList(id)
{
var selectList = document.getElementById(id);
var selectOptions = selectList.getElementsByTagName('option');
var listString = "";
for (var i = 0; i < selectOptions.length; i++)
{
listString += selectOptions[i].value;
if(i < selectOptions.length - 1)
listString += ":";
}//end for
return listString;
}//end generateBootList
/**
* Function to reset the boot list options to the orignal state
*
* @param {String} keyId The key of the option that needs to be reset
* @param {String} currentSettingForKey The current setting string for that key
*/
function resetBootLists(keyId, currentSettingForKey)
{
var bootSelectList = document.getElementById(keyId + "bootList");
var excludeSelectList = document.getElementById(keyId + "right");
var optionsForBootSelect = bootSelectList.getElementsByTagName('option');
var optionsForExcludeSelect = excludeSelectList.getElementsByTagName('option');
var allOptions = [];
for(var i = 0; i < optionsForBootSelect.length; i++)
allOptions.push(optionsForBootSelect[i]);
for(var i = 0; i < optionsForExcludeSelect.length; i++)
allOptions.push(optionsForExcludeSelect[i]);
bootSelectList.InnerHTML = "";
excludeSelectList.InnerHTML = "";
var splitSettings = currentSettingForKey.split(":");
for(var i = 0; i < splitSettings.length; i++)
{
var settingName = splitSettings[i];
for(var j = 0; j < allOptions.length; j++)
{
if(allOptions[j].value == settingName)
{
bootSelectList.appendChild(allOptions[j]);
allOptions.splice(j, 1);
}//end if
}//end for
}//end for
for(var i = 0; i < allOptions.length; i++)
excludeSelectList.appendChild(allOptions[i]);
}//end resetBootLists
/**
* Some keys have < and > in the name.
* These need to be replaced before it can be displayed properly in HTML
*
* @param {String} str The name of the option.
* @returs {String} A modified version of the string with HTMl character codes embedded.
*/
function replaceSymbols(str)
{
return str.replace("<", "&lt;").replace(">", "&gt;");
}//end replaceSymbols
function isAlphaNumeric(str) {
var code, i, len;
for (i = 0, len = str.length; i < len; i++)
{
code = str.charCodeAt(i);
if (!(code > 47 && code < 58) && // (0-9)
!(code > 64 && code < 91) && // (A-Z)
!(code > 96 && code < 123)) // (a-z)
return false;
}
return true;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
</script>
<body onbeforeunload="checkForPendingChanges">
<div id="titlebar" class="titlebar">
<h2>Think BIOS Configurator</h2>
</div>
<div id="fileActions" class="fileactions">
<strong>File Actions:<strong>
<table id="file_actions" cellpadding="20px">
<tr>
<td width="50%">
<p>
Select a previously created .ini file of settings
</p>
<input name="file" class="file" type="file" size="50" onChange="CheckFile"/><br><br>
<input type="button" class="btn" id="configButton" value="Apply Settings File" name="file_button" onClick="ApplyFile" disabled="true">
</td>
<td style="border-left:solid 2px #000;">
<p>Create an .ini file containing the current settings of the target machine in the working directory.</p>
<input type="button" class="btn" value="Export Settings" name="export_button" onClick="ExportChanges"> <br>
<br>
</td>
</tr>
</table>
</div>
<div id="security">
<strong>Security Actions:</strong>
<table id="security_actions" cellpadding="20px">
<tr>
<td width="50%">
<input type="checkbox" id="supervisor" value="Yes" onClick="showPasswordInfoSub" style="width:30px;height:30px;margin-right:20px;">Supervisor password set on the target machine
<div id="passwordStuff" class="passwordstuff"></div>
</td>
<td style="border-left:solid 2px #000;">
<input type="checkbox" id="user" value="Yes" onClick="ShowUserInfoSub" style="width:30px;height:30px;margin-right:20px;">Use different credentials to connect to target machine
<div id="userStuff" class="passwordstuff"></div>
</td>
</tr>
</table>
</div>
<div id="targeting_div">
<strong>Targeting:</strong><br><br>
<input type="button" class="btn" id="localButton" value="Target Local" name="local_button" onClick="LocalSub">
<input type="button" class="btn" id="remoteButton" value="Target Remote" name="remote_button" onClick="RemoteSub">
<br><br>
</div>
<div id="data_title">
<br>
<table id="targeted_settings" style="width:100%" cellpadding="14px">
<tr>
<td><center><span id="targeting"></span></center></td>
</tr>
<tr>
<td>
<center>
<input type="button" class="btn" id="saveButton" value="Save Changed Settings" name="save_button" onClick="SaveChanges">
<input type="button" class="btn" value="Restore BIOS Defaults" name="default_button" onClick="SetDefaults">
<input type="button" class="btn" id="resetButton" value="Reset to Current Settings" name="reset_button" onClick="ResetSub">
</center>
</td>
</tr>
<tr>
<td>
<div id="dataArea" align="center" style="overflow:scroll">Loading data...</div>
</td>
</tr>
</table>
</div>
</body>
</html>