Hallo ihr Zwei,
also bei meinem UseCase fällt das nicht so ins Gewicht. Da reden wir, nach meinen Tests auf den bei uns existierenden Rechnern, von
unter hundert Bios-Optionen, sprich Einträgen.
Aber ich gebe Bugfix recht, sollte jemand das für deutlich größere Datenmengen, bzw. Arrays einsetzen ist das sicherlich das bessere Vorgehen.
Das Tool ist von meiner Seite aus fertig und somit auch dieser Post. Ich lasse ihn aber noch ein paar Tage offen falls wer noch Fragen hat oder weiter diskutieren möchte
Nochmals vielen herzlichen Dank an euch beide. Ihr wart mir wie immer eine große Hilfe und Bereicherung
C
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile_x64=BiosDump.Exe
#AutoIt3Wrapper_Res_Fileversion=1.0.0.1
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_LegalCopyright=by HaSc
#AutoIt3Wrapper_Res_Field=Made By|HaSc
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/MO
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
; #INDEX# =======================================================================================================================
; Title .........: BiosDump.au3
; AutoIt Version : 3.3.14.2
; Language ......: English
; Description ...: Reading out the current Bios-Options from Dell, HP and Lenovo Computers and save it into Txt-file
; Author(s) .....: HaSc. Developed with the generous assistance of Moombas and Bugfix from the german Autoit-Forum.
; Many and sincere thanks for your assistance!!!!!!!!!!!
; ===============================================================================================================================
#include <Array.au3>
#include <AutoItConstants.au3>
#include <WinAPI.au3>
#include <WinAPIFiles.au3>
#include <WinAPIShPath.au3>
#include <WindowsConstants.au3>
#include <File.au3>
Global $sModelvendor = Vend()
Global $sComputermodel = Compmod()
Global $sFilePath = "./BiosDump.txt"
Global $Comp = @ComputerName
Global $s_Dumptxt = ""
Switch $sModelvendor
Case "LENOVO"
If $sComputermodel = "THINKPAD" Then
$hFileOpen = FileOpen($sFilePath, $FO_APPEND)
If $hFileOpen = -1 Then
MsgBox($MB_SYSTEMMODAL, "", "An error occurred while reading the file.")
EndIf
FileWrite($hFileOpen, $s_Dumptxt)
_FileWriteFromArray($hFileOpen, LEN_LappiBiosSettings())
Else
$hFileOpen = FileOpen($sFilePath, $FO_APPEND)
If $hFileOpen = -1 Then
MsgBox($MB_SYSTEMMODAL, "", "An error occurred while reading the file.")
EndIf
FileWrite($hFileOpen, $s_Dumptxt)
_FileWriteFromArray($hFileOpen, LEN_DesktopBiosSettings())
EndIf
Case "HP"
$s_Dumptxt = HP_BiosSettings()
$hFileOpen = FileOpen($sFilePath, $FO_APPEND)
If $hFileOpen = -1 Then
MsgBox($MB_SYSTEMMODAL, "", "An error occurred while reading the file.")
EndIf
FileWrite($hFileOpen, $s_Dumptxt)
Case "DELL"
$s_Dumptxt = Dell_BiosSettings()
$hFileOpen = FileOpen($sFilePath, $FO_APPEND)
If $hFileOpen = -1 Then
MsgBox($MB_SYSTEMMODAL, "", "An error occurred while reading the file.")
EndIf
FileWrite($hFileOpen, $s_Dumptxt)
Case "HEWLETT-PACKARD"
$s_Dumptxt = HP_BiosSettings()
$hFileOpen = FileOpen($sFilePath, $FO_APPEND)
If $hFileOpen = -1 Then
MsgBox($MB_SYSTEMMODAL, "", "An error occurred while reading the file.")
EndIf
FileWrite($hFileOpen, $s_Dumptxt)
Case Else
MsgBox($MB_SYSTEMMODAL, "351: Wrong Vendor", "Error: The Vendor from this device is not supported right now!" & @CRLF & @CRLF & "Program termination!")
Sleep(2000)
Exit
EndSwitch
; #FUNCTION LEN_LappiBiosSettings()# ===============================================================================================
; Author ........: Bugfix, HaSc
; Description....: Reading out the Bios-Options on Lenovo Laptop Computers. I decided to create another function for the desktop
; computers, because Lenovo laptops and desktops have their bios from different manufacturers.
; If the necessary WMI classes change with one of the BIOS manufacturers, this can then be adapted more easily.
; ==================================================================================================================================
Func LEN_LappiBiosSettings()
; Teilweise erstellt von AutoIt Scriptomatic
Local $wbemFlagReturnImmediately = 0x10
Local $wbemFlagForwardOnly = 0x20
Local $colItems = ""
Local $strComputer = "localhost"
Local $aBiosArray[200][2]
Local $nCount = 0, $sSetting, $aSplit
Local $a_String
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\WMI")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Lenovo_BiosSetting", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
For $objItem In $colItems
$sSetting = $objItem.CurrentSetting
If $sSetting <> "" Then
$aSplit = StringSplit($sSetting, ",")
$aBiosArray[$nCount][0] = $aSplit[1]
$aBiosArray[$nCount][1] = $aSplit[2]
$nCount += 1
EndIf
Next
ReDim $aBiosArray[$nCount + 1][2]
Else
MsgBox(0, "WMI-Ausgabe", "Keine WMI-Objekte gefunden für Klasse: " & "Lenovo_BiosSetting")
EndIf
Return $aBiosArray
EndFunc ;==>LEN_LappiBiosSettings
; #FUNCTION LEN_DesktopBiosSettings()# =============================================================================================
; Author ........: Bugfix, HaSc
; Description....: Reading out the Bios-Options on Lenovo Desktop Computers. I decided to create another function for the desktop
; computers, because Lenovo laptops and desktops have their bios from different manufacturers.
; If the necessary WMI classes change with one of the BIOS manufacturers, this can then be adapted more easily.
; =================================================================================================================================
Func LEN_DesktopBiosSettings()
Local $wbemFlagReturnImmediately = 0x10
Local $wbemFlagForwardOnly = 0x20
Local $colItems = ""
Local $strComputer = "localhost"
Local $aBiosArray[200][2]
Local $nCount = 0, $sSetting, $aSplit
Local $a_String
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\WMI")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Lenovo_BiosSetting", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
For $objItem In $colItems
$sSetting = $objItem.CurrentSetting
If $sSetting <> "" Then
$aSplit = StringSplit($sSetting, ",")
$aBiosArray[$nCount][0] = $aSplit[1]
$aBiosArray[$nCount][1] = $aSplit[2]
$nCount += 1
EndIf
Next
ReDim $aBiosArray[$nCount + 1][2]
Else
MsgBox(0, "WMI-Ausgabe", "Keine WMI-Objekte gefunden für Klasse: " & "Lenovo_BiosSetting")
EndIf
Return $aBiosArray
EndFunc ;==>LEN_DesktopBiosSettings
#FUNCTION HP_BiosSettings()# ====================================================================================================
; Author ........: HaSc
; ===============================================================================================================================
Func HP_BiosSettings()
; Teilweise erstellt von AutoIt Scriptomatic
Local $wbemFlagReturnImmediately = 0x10
Local $wbemFlagForwardOnly = 0x20
Local $colItems = ""
Local $strComputer = "localhost"
Local $aBiosArray[1]
Local $s_aString
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\HP\InstrumentedBIOS")
$colItems = $objWMIService.ExecQuery("SELECT * FROM HP_BIOSEnumeration", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
For $objItem In $colItems
ReDim $aBiosArray[UBound($aBiosArray) + 1]
$aBiosArray[UBound($aBiosArray) - 1] = "AttributeName: " & $objItem.Name & " -- CurrentSetting: " & $objItem.CurrentValue
If $objItem.CurrentValue = "" Then
ReDim $aBiosArray[UBound($aBiosArray) - 1]
EndIf
Next
Else
MsgBox(0, "WMI-Ausgabe", "No WMI objects found for class: " & "HP_BIOSEnumeration")
EndIf
$s_aString = _ArrayToString($aBiosArray, @CRLF)
Return $s_aString
EndFunc ;==>HP_BiosSettings
#FUNCTION DELL_BiosSettings()# ==================================================================================================
; Author ........: HaSc
; ===============================================================================================================================
Func Dell_BiosSettings()
; Teilweise erstellt von AutoIt Scriptomatic
Local $wbemFlagReturnImmediately = 0x10
Local $wbemFlagForwardOnly = 0x20
Local $colItems = ""
Local $strComputer = "localhost"
Local $aBiosArray[1]
Local $s_aString
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\Dcim\sysman\biosattributes")
$colItems = $objWMIService.ExecQuery("SELECT * FROM EnumerationAttribute", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
For $objItem In $colItems
ReDim $aBiosArray[UBound($aBiosArray) + 1]
$aBiosArray[UBound($aBiosArray) - 1] = "AttributeName: " & $objItem.AttributeName & " -- CurrentSetting: " & $objItem.CurrentValue
If $objItem.CurrentValue = "" Then
ReDim $aBiosArray[UBound($aBiosArray) - 1]
EndIf
Next
Else
MsgBox(0, "WMI-Ausgabe", "No WMI objects found for class: " & "EnumerationAttribute")
EndIf
$s_aString = _ArrayToString($aBiosArray, @CRLF)
Return $s_aString
EndFunc ;==>Dell_BiosSettings
#FUNCTION Vend()# ===============================================================================================================
; Author ........: HaSc
; ===============================================================================================================================
Func Vend() ;Auslesen Vendor aus WMI
Local $Modelvendor = ObjGet("winmgmts:\\localhost\root\CIMV2").ExecQuery("SELECT Vendor FROM Win32_ComputerSystemProduct", "WQL", 0).ItemIndex(0).Vendor
Local $aArray1 = StringSplit($Modelvendor, " ")
$sString1 = StringUpper($aArray1[1]) ; String in Großbuchstaben umwandeln
If $sString1 <> "LENOVO" And $sString1 <> "HP" And $sString1 <> "HEWLETT-PACKARD" And $sString1 <> "DELL" Then
MsgBox($MB_SYSTEMMODAL, "351: Wrong Vendor", "Error: The Vendor from this device is not supported right now!" & @CRLF & @CRLF & "Program termination!")
Sleep(300)
Exit
Else
If Not FileWrite($sFilePath, " 0-series-test biosdump from " & $Comp & @CRLF & " ----------------------------------------" & @CRLF & @CRLF) Then
MsgBox($MB_SYSTEMMODAL, "", "An error occurred while writing the temporary file.")
EndIf
EndIf
$aArray1 = Null
Return $sString1
EndFunc ;==>Vend
#FUNCTION Compmod()# ============================================================================================================
; Author ........: HaSc
; ===============================================================================================================================
Func Compmod()
If $sModelvendor = "LENOVO" Then
$Modelmod = ObjGet("winmgmts:\\localhost\root\CIMV2").ExecQuery("SELECT Version FROM Win32_ComputerSystemProduct", "WQL", 0).ItemIndex(0).Version
Local $aArray = StringSplit($Modelmod, " ") ; Modell aus Text extrahieren
Local $sVar = $aArray[1] ; ThinkPad, Thinkcenter oder Thinkstation
$sString = StringUpper($sVar) ; String in Großbuchstaben umwandeln
$aArray = Null ; $arBase[1]
Return $sString
EndIf
$sVar = ""
EndFunc ;==>Compmod
Alles anzeigen