|
#NoTrayIcon
这是一个查硬件信息的脚本,可以自动上传服务器.防止有些网络不通的问题,想实现如果不通自己保存到本地,还请朋友们帮忙!谢了
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=..\users.ico
#AutoIt3Wrapper_outfile=hard.exe
#AutoIt3Wrapper_Compression=3
#AutoIt3Wrapper_Res_Comment=http://www.wa.com.cn
#AutoIt3Wrapper_Res_Description=信息部
#AutoIt3Wrapper_Res_Fileversion=1.0.0.41
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_LegalCopyright=itcenter
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#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 = RegRead ( "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "Hostname") ;计算机名
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", "Storage|Optical Drive1", ""), "'", ""), '"', "") ;光驱
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
MsgBox("0","信息部提示","系统信息已上传成功!","5") |
|