#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#NoTrayIcon
$mdb_data_path="au3.mdb"
$mdb_data_pwd=""
$tblname="COMPUTER"
;获得本机地址与MAC
Runwait(@comspec & " /c ipconfig /all > c:\connect.txt","",@sw_hide)
$file1 = FileOpen("c:\connect.txt", 0)
$len = StringLen(" Physical Address. . . . . . . . . : ")
While 1
$line = FileReadLine($file1)
If @error = -1 Then ExitLoop
If StringLeft($line,$len) = " Physical Address. . . . . . . . . : " then
$mymac = StringMid($line,$len + 1)
endif
Wend
FileClose($file1)
FileDelete("c:\connect.txt")
;~ 框架部分
Opt('GUICloseOnESC', 0)
GUICreate ("EDP",310,375)
$ccc=GUICtrlCreateButton("退出",220,340,80,25)
$Save=GUICtrlCreateButton("保存配置",130,340,80,25)
$close=GUICtrlCreateLabel("提示:固定资产盘点",10,340,110,25)
GUICtrlCreateLabel("描述",10,10,60,25)
GUICtrlSetColor(-1,0x000000)
$regcomputername1 = RegRead( "HKLM\SYSTEM\ControlSet001\Services\lanmanserver\parameters", "srvcomment" )
$computername1=GUICtrlCreateInput($regcomputername1 ,50,10,250,20)
GUICtrlCreateLabel("名称",10,30,60,30)
GUICtrlSetColor(-1,0x000000)
$regcomputername = RegRead( "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName", "ComputerName" )
$computername=GUICtrlCreateInput($regcomputername ,50,30,250,20)
GUICtrlCreateLabel("帐户",10,50,60,30)
GUICtrlSetColor(-1,0x000000)
$regcomputeruser = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName")
$computeruser=GUICtrlCreateInput($regcomputeruser ,50,50,250,20)
GUICtrlCreateLabel("主板",10,70,60,30)
GUICtrlSetColor(-1,0x000000)
$board=GUICtrlCreateInput("",50,70,250,20)
GUICtrlCreateLabel("CPU",10,90,60,30)
GUICtrlSetColor(-1,0x000000)
$cpu=GUICtrlCreateInput("",50,90,250,20)
GUICtrlCreateLabel("显卡",10,110,60,30)
GUICtrlSetColor(-1,0x000000)
$display=GUICtrlCreateInput("",50,110,250,20)
GUICtrlCreateLabel("硬盘",10,130,60,30)
GUICtrlSetColor(-1,0x000000)
$harddisk=GUICtrlCreateInput("",50,130,250,20)
GUICtrlCreateLabel("内存",10,150,60,30)
GUICtrlSetColor(-1,0x000000)
$Memory=GUICtrlCreateInput("",50,150,250,20)
GUICtrlCreateLabel("网卡",10,170,60,30)
GUICtrlSetColor(-1,0x000000)
$network=GUICtrlCreateInput("",50,170,250,20)
GUICtrlCreateLabel("声卡",10,190,60,30)
GUICtrlSetColor(-1,0x000000)
$sound=GUICtrlCreateInput("",50,190,250,20)
GUICtrlCreateLabel("系统",10,210,60,30)
GUICtrlSetColor(-1,0x000000)
$Windows_System=GUICtrlCreateInput("",50,210,250,20)
GUICtrlCreateLabel("Bios",10,230,60,30)
GUICtrlSetColor(-1,0x000000)
$bios=GUICtrlCreateInput("",50,230,250,20)
GUICtrlCreateLabel("IP",10,250,60,30)
GUICtrlSetColor(-1,0x000000)
TCPStartup()
$IPAddress=GUICtrlCreateInput(TCPNameToIP(@ComputerName) ,50,250,250,20)
GUICtrlCreateLabel("MAC",10,270,60,30)
GUICtrlSetColor(-1,0x000000)
TCPStartup()
$mymac=GUICtrlCreateInput($mymac ,50,270,250,20)
GUICtrlCreateLabel("光驱",10,290,60,30)
GUICtrlSetColor(-1,0x000000)
$cdrom=GUICtrlCreateInput("",50,290,250,20)
GUICtrlCreateLabel("显示器",10,310,60,30)
GUICtrlSetColor(-1,0x000000)
$monitor=GUICtrlCreateInput("",50,310,250,20)
GUISetState(@SW_SHOW)
$g_szVersion = "info"
If WinExists($g_szVersion) Then Exit
AutoItWinSetTitle($g_szVersion)
GUICtrlRead($computername)
info()
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
Case $Save
sx()
Case $ccc
Exit
EndSwitch
WEnd
Func info()
$objWMIService = objget("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
$colBios = $objWMIService.ExecQuery("Select * from Win32_BIOS")
$colBoard = $objWMIService.ExecQuery("Select * FROM Win32_BaseBoard")
$colSettings = $objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
$colMemory = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
$colCPU = $objWMIService.ExecQuery("Select * from CIM_Processor")
$colVideoinfo = $objWMIService.ExecQuery("Select * from Win32_VideoController")
$colSound = $objWMIService.ExecQuery("Select * from Win32_SoundDevice")
$colMouse = $objWMIService.ExecQuery("Select * from Win32_PointingDevice")
$colMonitor = $objWMIService.ExecQuery("Select * from Win32_DesktopMonitor")
$colNIC = $objWMIservice.ExecQuery("Select * from Win32_NetworkAdapter Where Netconnectionstatus = 2")
$colharddisk =$objwmiservice.execQuery("select * from win32_diskdrive")
$colcdrom =$objwmiservice.execQuery("select * from win32_CDROMDrive")
For $object in $colBios
GUICtrlSetData($bios,StringMid($object.Caption,1))
ExitLoop
Next
For $object in $colcdrom
GUICtrlSetData($cdrom,StringMid($object.Caption,1))
ExitLoop
Next
For $object in $colMonitor
GUICtrlSetData($monitor,StringMid($object.Caption,1))
ExitLoop
Next
For $object in $colBoard
GUICtrlSetData($board,$object.Product)
ExitLoop
Next
For $object in $colCPU
GUICtrlSetData($cpu, StringStripWS($object.Name,1))
ExitLoop
Next
For $object in $colVideoinfo
GUICtrlSetData($display, StringStripWS($object.Description ,1))
ExitLoop
Next
For $object in $colSound
GUICtrlSetData($sound, StringStripWS($object.Description ,1))
ExitLoop
Next
For $object in $colNIC
GUICtrlSetData($network, StringStripWS($object.name ,1))
ExitLoop
Next
For $objOperatingSystem in $colSettings
GUICtrlSetData($Windows_System,$objOperatingSystem.Caption & " Build " & $objOperatingSystem.BuildNumber & " Sp " & $objOperatingSystem.ServicePackMajorVersion & "." & $objOperatingSystem.ServicePackMinorVersion )
ExitLoop
Next
for $object in $colMemory
GUICtrlSetData($Memory,String(Int(Number($object.TotalPhysicalMemory) / (1024 * 1024))) & " MB")
ExitLoop
Next
dim $all_Hard
For $object in $colHardDisk
$all_Hard=$all_Hard & ";" & StringMid($object.Caption,1)
Next
$all_Hard=StringMid($all_Hard,2)
GUICtrlSetData($harddisk,$all_Hard)
EndFunc
Func sx()
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$addfld.Execute("insert into COMPUTER (description,computer,username,motherboard,cpu,graphics,harddisk,memory,nic,sound,os,bios,ip,mac,dirve,monitors) values('"&$regcomputername1&"','"&$computername&"','"&$board&"','"&$cpu&"','"&$display&"','"&$harddisk&"','"&$Memory&"','"&$network$&"','"&$sound$&"','"&$Windows_System&"','"&$bios&"','"&$IPAddress&"','"&$mymac&"','"&$cdrom&"','"&$monitor&"')")
$addfld.close
MsgBox(4096, "提示:"," 成功写入数据库!")
EndFunc