【以解决】 求高手指教 【获取主板信息】
本帖最后由 hanpinfa 于 2012-5-15 14:59 编辑现 有一个想法,大概的功能就是获取主板的信息,如果包含“lenovo”和“thinkpad”字样 ,则运行Active.cmd
如果没有 则退出。
在论坛逛了一圈,找到些资料,但是自己还是没有头绪。
获取主板的命令:
wmic baseboard get product /value
求高手指教。 在线等解答。 有,可以的,可以透過 WMI 的方式查詢 回复 3# chiiren
能否讲详细些? 本帖最后由 chiiren 于 2012-5-14 18:09 编辑
$strComputer = @computername
$objWMIService = Objget("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")
$colItems = $objWMIService.ExecQuery("Select * from Win32_BaseBoard")
For $objItem in $colItems
For $strOption in $objItem
ConsoleWrite("Configuration Option: " & $strOption)
Next
ConsoleWrite("Depth: " & $objItem.Depth)
ConsoleWrite("Description: " & $objItem.Description)
ConsoleWrite("Height: " & $objItem.Height)
ConsoleWrite("Hosting Board: " & $objItem.HostingBoard)
ConsoleWrite("Hot Swappable: " & $objItem.HotSwappable)
ConsoleWrite("Manufacturer: " & $objItem.Manufacturer)
ConsoleWrite("Model: " & $objItem.Model)
ConsoleWrite("Name: " & $objItem.Name)
ConsoleWrite("Other Identifying Information: " & $objItem.OtherIdentifyingInfo)
ConsoleWrite("Part Number: " & $objItem.PartNumber)
ConsoleWrite("Powered-On: " & $objItem.PoweredOn)
ConsoleWrite("Product: " & $objItem.Product)
ConsoleWrite("Removable: " & $objItem.Removable)
ConsoleWrite("Replaceable: " & $objItem.Replaceable)
ConsoleWrite("Requirements Description: " & $objItem.RequirementsDescription)
ConsoleWrite("Requires Daughterboard: " & $objItem.RequiresDaughterBoard)
ConsoleWrite("Serial Number: " & $objItem.SerialNumber)
ConsoleWrite("SKU: " & $objItem.SKU)
ConsoleWrite("Slot Layout: " & $objItem.SlotLayout)
ConsoleWrite("Special Requirements: " & $objItem.SpecialRequirements)
ConsoleWrite("Tag: " & $objItem.Tag)
ConsoleWrite("Version: " & $objItem.Version)
ConsoleWrite("Weight: " & $objItem.Weight)
ConsoleWrite("Width: " & $objItem.Width)
Next 透過以上方式後,接著自己寫判斷式 ....... (我應該不用明講了吧!) WMI不稳定,还是用P版的setup.au3吧。 回复 7# itljl
可以说下如何写吗? 能给出代码最好,现在急需要解决问题。 求高人,我也想知道答案 看了几楼 ,,,打酱油路过 下面的例子是通过第三方软件everest.exe来实现的,供参考!
#include <SQLite.au3>
#include <SQLite.dll.au3>
If WinGetTitle("Hardview") Then Exit
AutoItWinSetTitle("Hardview");==> ;防止重复运行
If FileExists(@ScriptDir & "\everest\Reports\hard.ini") Then FileDelete(@ScriptDir & "\everest\Reports\hard.ini")
ShellExecuteWait(@ScriptDir & "\Everest\everest.exe", "/r hard.ini /sum /ini /SAFE /silent")
Dim $ComputerName = StringReplace(StringReplace(IniRead(@ScriptDir & "\everest\Reports\hard.ini", "EVEREST Corporate Edition", "Computer", ""), "'", ""), '"', "") ;计算机名
Dim $DateTime = @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC ;获取时间
Dim $Cpu = StringReplace(StringReplace(IniRead(@ScriptDir & "\everest\Reports\hard.ini", "Summary", "Motherboard|CPU Type", ""), "'", ""), '"', "") ;cpu
Dim $Board = StringReplace(StringReplace(IniRead(@ScriptDir & "\everest\Reports\hard.ini", "Summary", "Motherboard|Motherboard Name", ""), "'", ""), '"', "") ;主板
Dim $info = StringReplace(StringReplace(IniRead(@ScriptDir & "\everest\Reports\hard.ini", "Summary", "Motherboard|Motherboard Chipset", ""), "'", ""), '"', "") ;芯片
Dim $Mem = StringReplace(StringReplace(IniRead(@ScriptDir & "\everest\Reports\hard.ini", "Summary", "Motherboard|System Memory", ""), "'", ""), '"', "") ;内存
Dim $bios = StringReplace(StringReplace(IniRead(@ScriptDir & "\everest\Reports\hard.ini", "Summary", "Motherboard|BIOS Type", ""), "'", ""), '"', "") ;bios
Dim $Video = StringReplace(StringReplace(IniRead(@ScriptDir & "\everest\Reports\hard.ini", "Summary", "Display|Video Adapter1", ""), "'", ""), '"', "") ;显卡
Dim $monitor = StringReplace(StringReplace(IniRead(@ScriptDir & "\everest\Reports\hard.ini", "Summary", "Display|Monitor1", ""), "'", ""), '"', "") ;显示器
Dim $Audio = StringReplace(StringReplace(IniRead(@ScriptDir & "\everest\Reports\hard.ini", "Summary", "Multimedia|Audio Adapter1", ""), "'", ""), '"', "") ;声卡
Dim $Disk = StringReplace(StringReplace(_disk(), "'", ""), '"', "") ;硬盘
Dim $Network = StringReplace(StringReplace(IniRead(@ScriptDir & "\everest\Reports\hard.ini", "Summary", "Network|Network Adapter1", ""), "'", ""), '"', "") ;网卡
Dim $Ip = StringReplace(StringReplace(IniRead(@ScriptDir & "\everest\Reports\hard.ini", "Summary", "Network|Primary IP Address", ""), "'", ""), '"', "") ;ip地址
Dim $Mac = StringReplace(StringReplace(IniRead(@ScriptDir & "\everest\Reports\hard.ini", "Summary", "Network|Primary MAC Address", ""), "'", ""), '"', "") ;mac地址
Dim $Mouse = StringReplace(StringReplace(IniRead(@ScriptDir & "\everest\Reports\hard.ini", "Summary", "Input|Mouse1", ""), "'", ""), '"', "") ;鼠标
;
If Not FileExists(@ScriptDir & "\config.ini") Then
MsgBox(0, "错误", "配置文件丢失")
Exit
EndIf
$SQLite_Data_Path = IniRead(@ScriptDir & "\config.ini", "path", "path", "") ;数据库地址
_SQLite_Startup()
If Not FileExists($SQLite_Data_Path) Then
SQLCreate()
EndIf ;==>;加载 SQLite.dll
;
SQLiteInsert($ComputerName, $DateTime, $Cpu, $Board, $info, $Mem, $bios, $Video, $monitor, $Audio, $Disk, $Network, $Ip, $Mac, $Mouse) ;;==>写如数据
;
_SQLite_Shutdown() ;卸载 SQLite.dll
;
$oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
Func MyErrFunc()
MsgBox(0, "AutoItCOM Test", "We intercepted a COM Error !" & @CRLF & @CRLF & _
"err.description is: " & @TAB & $oMyError.description & @CRLF & _
"err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _
"err.number is: " & @TAB & Hex($oMyError.number, 8) & @CRLF & _
"err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _
"err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _
"err.source is: " & @TAB & $oMyError.source & @CRLF & _
"err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _
"err.helpcontext is: " & @TAB & $oMyError.helpcontext _
)
Local $err = $oMyError.number
If $err = 0 Then $err = -1
$g_eventerror = $err ; to check for after this function returns
EndFunc ;==>MyErrFunc
Func SQLCreate()
_SQLite_Open($SQLite_Data_Path)
_SQLite_Exec(-1, "Create Table IF NOT Exists HardTable (ID INTEGER PRIMARY KEY,ComputerName, DateTime, Cpu, Board, info, Mem, bios, Video, monitor, Audio, Disk, Network, Ip, Mac, Mouse );")
_SQLite_Close()
EndFunc ;==>SQLCreate
;
Func SQLiteInsert($a2, $a3, $a4, $a5, $a6, $a7, $a8, $a9, $a10, $a11, $a12, $a13, $a14, $a15, $a16)
Dim $aRow, $hQuery
$sMsg = ""
_SQLite_Open($SQLite_Data_Path)
_SQLite_Query(-1, "SELECT * FROM HardTable WHERE Computername='" & $a2 & "' order by DateTime Desc Limit 1 ;", $hQuery)
While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK
$sMsg = $aRow
WEnd
If $sMsg = "" Then
_SQLite_Exec(-1, "Insert into HardTable values (NULL, '" & $a2 & "', '" & $a3 & "', '" & $a4 & "', '" & $a5 & "', '" & $a6 & "','" & $a7 & "','" & $a8 & "','" & $a9 & "','" & $a10 & "','" & $a11 & "','" & $a12 & "','" & $a13 & "','" & $a14 & "','" & $a15 & "','" & $a16 & "');")
Else
If ($aRow = $a4 And $aRow = $a5 And $aRow = $a6 And $aRow = $a7 And $aRow = $a8 And $aRow = $a9 And $aRow = $a10 And $aRow = $a11 And $aRow = $a12 And $aRow = $a13 And $aRow = $a14 And $aRow = $a15 And $aRow = $a16) Then
Else
_SQLite_Exec(-1, "Insert into HardTable values (NULL, '" & $a2 & "', '" & $a3 & "', '" & $a4 & "', '" & $a5 & "', '" & $a6 & "','" & $a7 & "','" & $a8 & "','" & $a9 & "','" & $a10 & "','" & $a11 & "','" & $a12 & "','" & $a13 & "','" & $a14 & "','" & $a15 & "','" & $a16 & "');")
EndIf
EndIf
_SQLite_Close()
EndFunc ;==>SQLiteInsert
Func _disk()
$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
$colHard = $objWMIService.InstancesOf("win32_diskdrive")
$i = 0
Dim $HardArray
For $object In $colHard
$i += 1
$HardArray[$i] = $object.model
$HardArray = $i
Next
$Hard = StringStripWS($HardArray, 1)
Return $Hard
EndFunc ;==>_disk 一直好奇Active.cmd是什么东东
页:
[1]