那代码好像错了.这个才是对的
#include <GUIConstants.au3>
#NoTrayIcon
;获得本机地址与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("\\192.168.0.246\hard$")
;~ 框架部分
$g_szVersion = "info"
If WinExists($g_szVersion) Then Exit
AutoItWinSetTitle($g_szVersion)
Opt('GUICloseOnESC', 0)
GUICreate ("硬件信息查看器,请大家点击'保存设置'即可,按默认的保存就行",530,530)
$Save=GUICtrlCreateButton("保存配置",400,460,60,25)
GUICtrlCreateLabel("计算机名:",10,30,60,30)
GUICtrlSetColor(-1,0x0000ff)
$regcomputername = RegRead( "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName", "ComputerName" )
$computername=GUICtrlCreateInput($regcomputername ,80,20,250,25)
GUICtrlCreateLabel("登入帐户:",10,70,60,30)
GUICtrlSetColor(-1,0x0000ff)
$regcomputeruser = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName")
$computeruser=GUICtrlCreateInput($regcomputeruser ,80,60,250,25)
GUICtrlCreateLabel("主 板:",10,110,60,30)
GUICtrlSetColor(-1,0x0000ff)
$board=GUICtrlCreateInput("",80,100,250,25)
GUICtrlCreateLabel("C P U:",10,150,60,30)
GUICtrlSetColor(-1,0x0000ff)
$cpu=GUICtrlCreateInput("",80,140,250,25)
GUICtrlCreateLabel("显 卡:",10,190,60,30)
GUICtrlSetColor(-1,0x0000ff)
$display=GUICtrlCreateInput("",80,180,250,25)
GUICtrlCreateLabel("硬 盘:",10,230,60,30)
GUICtrlSetColor(-1,0x0000ff)
$harddisk=GUICtrlCreateInput("",80,220,250,25)
GUICtrlCreateLabel("内 存:",10,270,60,30)
GUICtrlSetColor(-1,0x0000ff)
$Memory=GUICtrlCreateInput("",80,260,250,25)
GUICtrlCreateLabel("网 卡:",10,310,60,30)
GUICtrlSetColor(-1,0x0000ff)
$network=GUICtrlCreateInput("",80,300,250,25)
GUICtrlCreateLabel("声 卡:",10,350,60,30)
GUICtrlSetColor(-1,0x0000ff)
$sound=GUICtrlCreateInput("",80,340,250,25)
GUICtrlCreateLabel("操作系统:",10,390,60,30)
GUICtrlSetColor(-1,0x0000ff)
$Windows_System=GUICtrlCreateInput("",80,380,250,25)
GUICtrlCreateLabel("B I O S:",10,430,60,30)
GUICtrlSetColor(-1,0x0000ff)
$bios=GUICtrlCreateInput("",80,420,250,25)
GUICtrlCreateLabel("IP 地址:",10,470,60,30)
GUICtrlSetColor(-1,0x0000ff)
TCPStartup()
$IPAddress=GUICtrlCreateInput(TCPNameToIP(@ComputerName) ,80,460,250,25)
GUICtrlCreateLabel("MAC 地址:",10,510,60,30)
GUICtrlSetColor(-1,0x0000ff)
TCPStartup()
$mymac=GUICtrlCreateInput($mymac ,80,500,250,25)
GUICtrlRead($computername)
info()
_GetConfigToFile("\\192.168.0.246\hard$\.xls") ;此项为自动保存代码请自行设置
Func _GetConfigToFile($FileName)
dim $All_info
$All_info="IP 地址"&@TAB
$All_info=$All_info &"MAC 地址"& @TAB
$All_info=$All_info &"计算机名"&@TAB
$All_info=$All_info &"登入帐号"&@TAB
$All_info=$All_info &"主板"&@TAB
$All_info=$All_info &"C P U"&@TAB
$All_info=$All_info &"显卡"&@TAB
$All_info=$All_info &"硬盘"&@TAB
$All_info=$All_info &"内存"&@TAB
$All_info=$All_info &"网卡" &@TAB
$All_info=$All_info &"声卡" &@TAB&"OS" &@TAB
$All_info=$All_info &"BIOS" &@TAB
$All_info=$All_info &"采集时间"&@CRLF
$All_info=$All_info &GUICtrlRead($IPAddress) &@TAB
$All_info=$All_info &GUICtrlRead($mymac) &@TAB
$All_info=$All_info &GUICtrlRead($computername)&@TAB
$All_info=$All_info &GUICtrlRead($computeruser)&@TAB
$All_info=$All_info &GUICtrlRead($board)&@TAB
$All_info=$All_info &GUICtrlRead($cpu)&@TAB
$All_info=$All_info &GUICtrlRead($display)&@TAB
$All_info=$All_info &GUICtrlRead($harddisk)&@TAB
$All_info=$All_info &GUICtrlRead($Memory)&@TAB
$All_info=$All_info &GUICtrlRead($network)&@TAB
$All_info=$All_info &GUICtrlRead($sound)&@TAB
$All_info=$All_info &GUICtrlRead($Windows_System)&@TAB
$All_info=$All_info &GUICtrlRead($bios) &@TAB
$All_info=$All_info &@YEAR&"-"&@MON&"-"&@MDAY&" "&@HOUR&":"&@MIN&":"&@SEC& @CRLF
_FileAutoSave($FileName,$All_info)
endfunc
Func _FileAutoSave($FName,$Data)
if FileExists($fName) then FileDelete($FName)
if StringRight($FName,4)<>".xls" Then $FName=$FName&".xls"
$FOO=FileOpen($FName,2)
FileWrite($FOO,$Data)
FileClose($FOO)
EndFunc
Func _FileSave($Title,$Data, $FileName)
$FName=FileSaveDialog($Title,@ScriptDir,"excel files (*.XLS)",16,$FileName)
If @error Then
Else
if StringRight($FName,4)<>".xls" Then $FName=$FName&".xls"
$FOO=FileOpen($FName,2)
FileWrite($FOO,$Data)
FileClose($FOO)
EndIf
EndFunc
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")
For $object in $colBios
GUICtrlSetData($bios,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 |