找回密码
 加入
搜索
查看: 2957|回复: 6

保存为本地txt文本!求解...

[复制链接]
发表于 2010-1-19 08:38:50 | 显示全部楼层 |阅读模式
#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")
 楼主| 发表于 2010-1-19 08:39:58 | 显示全部楼层
我是新手期待各位的帮助!!!
发表于 2010-1-19 09:12:11 | 显示全部楼层
本帖最后由 水木子 于 2010-1-19 09:16 编辑

呵呵!果然还是用的everest,然后再提取everest生成的报告文件。

和我这个一样:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2010-1-19 11:50:58 | 显示全部楼层
"其实写什么并不重要,重要的是怎么写,怎么才能写得更好,继续加油吧!"精辟
发表于 2010-1-19 12:46:00 | 显示全部楼层
回复 4# ndyndy

呵呵!见笑啦!
发表于 2010-1-19 12:49:35 | 显示全部楼层
LZ是想将报告文件备份?直接将这个INI文件复制一份儿不就可以啦!
发表于 2010-1-19 15:18:40 | 显示全部楼层
回复 3# 水木子

水木子的这个很好,可否独立发布。
我看三恨的程序怎么没见到everest程序在哪里,不知道是怎么样做到的。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-21 20:41 , Processed in 0.079084 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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