找回密码
 加入
搜索
查看: 4164|回复: 11

[网络通信] 【以解决】 求高手指教 【获取主板信息】

  [复制链接]
发表于 2012-5-14 17:15:53 | 显示全部楼层 |阅读模式
本帖最后由 hanpinfa 于 2012-5-15 14:59 编辑

现 有一个想法,大概的功能就是获取主板的信息,如果包含“lenovo”和“thinkpad”字样 ,则运行Active.cmd
如果没有 则退出。


在论坛逛了一圈,找到些资料,但是自己还是没有头绪。

获取主板的命令:
wmic baseboard get product /value

求高手指教。
 楼主| 发表于 2012-5-14 17:20:51 | 显示全部楼层
在线等解答。
发表于 2012-5-14 18:02:03 | 显示全部楼层
有,可以的,可以透過 WMI 的方式查詢
 楼主| 发表于 2012-5-14 18:03:41 | 显示全部楼层
回复 3# chiiren


    能否讲详细些?
发表于 2012-5-14 18:08:11 | 显示全部楼层
本帖最后由 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
发表于 2012-5-14 18:11:18 | 显示全部楼层
透過以上方式後,接著自己寫判斷式 ....... (我應該不用明講了吧!)
发表于 2012-5-14 18:37:14 | 显示全部楼层
WMI不稳定,还是用P版的setup.au3吧。
 楼主| 发表于 2012-5-15 09:18:53 | 显示全部楼层
回复 7# itljl


    可以说下如何写吗? 能给出代码最好,现在急需要解决问题。
发表于 2012-5-15 09:23:24 | 显示全部楼层
求高人,我也想知道答案
发表于 2012-5-15 09:30:42 | 显示全部楼层
看了几楼 ,,,打酱油路过
发表于 2012-5-15 21:48:27 | 显示全部楼层
下面的例子是通过第三方软件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[0]
        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[3] = $a4 And $aRow[4] = $a5 And $aRow[5] = $a6 And $aRow[6] = $a7 And $aRow[7] = $a8 And $aRow[8] = $a9 And $aRow[9] = $a10 And $aRow[10] = $a11 And $aRow[11] = $a12 And $aRow[12] = $a13 And $aRow[13] = $a14 And $aRow[14] = $a15 And $aRow[15] = $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[128]
        For $object In $colHard
                $i += 1
                $HardArray[$i] = $object.model
                $HardArray[0] = $i
        Next
        $Hard = StringStripWS($HardArray[1], 1)
        Return $Hard
EndFunc   ;==>_disk
发表于 2012-5-15 22:05:48 | 显示全部楼层
一直好奇Active.cmd是什么东东
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-6-10 16:26 , Processed in 0.093915 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表