完善的局域网计算机维护通道源码(2015年2月5号更新)
本帖最后由 aiwen0092 于 2015-2-5 14:32 编辑完善的局域网计算机维护通道源码
功能有:1、运行自动添加启动项,启动项分为服务形式和注册表形式两种,考虑到是后台维护通道,两种启动方式都进行了伪装。
2、根据服务端设置客户端自动更新。
3、根据服务端设置同步服务器时间。
4、根据服务端设置更改IE主页。
5、根据服务端设置判断本地计算机是否运行本程序。
6、根据服务端设置跟换桌面背景,背景分为随机更换(最高只能100张图片,想要更高自己手动修改源码)和指定更换2种。
7、根据服务端设置禁止运行的进程。
8、根据服务端设置绑定ARP。
9、根据服务器设置执行服务器目录里面的所有REG、EXE、VBS、BAT文件。
10、收集客户端硬件信息、IP、MAC等信息到共享目录的EXCEL文件。
本程序所有源码来源于网络,感谢原作者!
本人技术有限,耗费月余时间把本程序完善,爬贴苦钱集源码,就只差超级版主没把我封号了,所以收点钱小伙伴们没意见吧!#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=E:\aiwen\计算机\工具\批处理转EXE工具\图标\清新系统桌面图标下载11.ico
#AutoIt3Wrapper_Res_Comment=局域网计算机维护通道
#AutoIt3Wrapper_Res_Description=局域网计算机维护通道
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=aiwen
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <Process.au3>
#include "ServiceControl.au3"
#include <Excel.au3>
;------------防再次运行---------------
$g_aiwen = "局域网计算机维护通道"
If WinExists($g_aiwen) = 1 Then
Exit
Else
AutoItWinSetTitle($g_aiwen)
EndIf
Opt("TrayIconHide",1)
HotKeySet("!0","_quit");退出
$servicename = "Netlaiwen"
Local $_RegRead = RegRead("HKLM\SYSTEM\CurrentControlSet\Services\" & $servicename, "ImagePath")
If @error Or $_RegRead <> @ScriptFullPath Then
If Not @error Then _DeleteService("", $servicename)
_CreateService("", $servicename, $servicename, @ScriptFullPath, "LocalSystem", "", 0x00000010)
RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\" & $servicename & "\Parameters", "Application", "REG_SZ", @ScriptFullPath)
RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\" & $servicename, "Description", 'REG_SZ', "如果此服务被停用,计算机可能无法验证用户和服务身份并且域控制器无法注册 DNS 记录。如果此服务被禁用,任何依赖它的服务将无法启动。")
EndIf
$_AutoRun_Name = '维护通道'
_AutoRun($_AutoRun_Name)
Func _AutoRun($_Progrem_Name)
Local $_RegRead = RegRead('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run', $_Progrem_Name)
If @error Or $_RegRead <> '"' & @ScriptFullPath & '"' Then
If Not @error Then RegDelete('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run', $_Progrem_Name)
Local $w = RegWrite('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run', $_Progrem_Name, 'REG_SZ', '"' & @ScriptFullPath & '"')
EndIf
EndFunc
$Serverip = iniread(@scriptdir & "\客户端配置.ini","默认配置","服务器IP","")
$User = iniread(@scriptdir & "\客户端配置.ini","默认配置","用户名","")
$Password = iniread(@scriptdir & "\客户端配置.ini","默认配置","密码","")
$Lord_server = IniRead(@scriptdir & "\客户端配置.ini", "默认配置", "主服务端路径", "")
$Serveri = iniread(@scriptdir & "\客户端配置.ini","配置","服务器IP","")
$Use = iniread(@scriptdir & "\客户端配置.ini","配置","用户名","")
$Passwor = iniread(@scriptdir & "\客户端配置.ini","配置","密码","")
$Pair_server = IniRead(@scriptdir & "\客户端配置.ini", "配置", "备服务端路径", "")
If @error Or IniReadSectionNames(@scriptdir & "\客户端配置.ini") Then
MsgBox(4096, "", "发生错误,客户端配置文件不存在或并非标准的INI文件.")
Exit
Endif
while 1
If Ping($Serverip) Then
DriveMapAdd("", $Lord_server, 0, $User, $Password)
If FileExists($Lord_server & "\服务端配置.ini") Then
$i_server = $Lord_server
ExitLoop
EndIf
EndIf
If Ping($Serveri) Then
DriveMapAdd("", $Pair_server, 0, $Use, $Passwor)
If FileExists($Pair_server & "\服务端配置.ini") Then
$i_server = $Pair_server
ExitLoop
EndIf
EndIf
Sleep(5000)
WEnd
;----------连网copy配置到本地------------
If FileExists(@ScriptDir & "\服务端配置.ini") Then FileDelete(@ScriptDir & "\服务端配置.ini");如果本地有服务端配置.ini就删除
While 1
Sleep(1000);延迟二秒再继续
If FileExists($i_server & "\服务端配置.ini") Then FileCopy($i_server & "\服务端配置.ini", @ScriptDir & "\服务端配置.ini", 1);copy配置到本地
Sleep(1000)
If FileExists(@ScriptDir & "\服务端配置.ini") = 1 Then ExitLoop;如果当前目录有"服务端配置.ini"就停止循环
WEnd
If @error Or IniReadSectionNames(@scriptdir & "\服务端配置.ini") Then
MsgBox(4096, "", "发生错误,服务端配置文件不存在或并非标准的INI文件.")
Exit
Endif
;---------------更新客户端------------
$update= iniread(@ScriptDir & "\服务端配置.ini","客户端更新","更新文件路径","")
If FileExists($update & "\*.bat") Then
$search = FileFindFirstFile($update &"\*.bat")
update()
Exit
EndIf
;---------------搜集客户端信息------------
$date= iniread(@ScriptDir & "\服务端配置.ini","客户端信息","信息路径","")
Global $bios = 0, $cpu = 0, $cdrom = 0, $board = 0, $display = 0, $sound = 0, $network = 0, $monitor = 0, $harddisk = 0, $all_Hard = 0, $Memory = 0, $MemorySpeed = 0, $Windows_System = 0, $sip = 0, $MAC = 0
$sip=@IPAddress1
If $sip="0.0.0.0" Then $sip=@IPAddress2
$MAC = _GetMAC($sip)
Func _GetMAC($sIP)
Local $MAC, $MACSize
Local $i, $s, $r, $iIP
$MAC = DllStructCreate("byte")
$MACSize = DllStructCreate("int")
DllStructSetData($MACSize, 1, 6)
$r = DllCall("Ws2_32.dll", "int", "inet_addr", "str", $sIP)
$iIP = $r
$r = DllCall("iphlpapi.dll", "int", "SendARP", "int", $iIP, "int", 0, "ptr", DllStructGetPtr($MAC), "ptr", DllStructGetPtr($MACSize))
$s = ""
For $i = 0 To 5
If $i Then $s = $s & "-"
$s = $s & Hex(DllStructGetData($MAC, 1, $i + 1), 2)
Next
Return $s
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")
$colMemorySpeed=$objwmiservice.execQuery("select * from Win32_PhysicalMemory")
$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
$bios = StringMid($object.Caption,1)
ExitLoop
Next
For $object in $colcdrom
$cdrom = StringMid($object.Caption,1)
ExitLoop
Next
For $object in $colMonitor
$monitor = StringMid($object.Caption,1)
ExitLoop
Next
For $object in $colBoard
$board = $object.Product
ExitLoop
Next
For $object in $colCPU
$cpu = StringStripWS($object.Name,1)
ExitLoop
Next
For $object in $colVideoinfo
$display = StringStripWS($object.Description ,1)
ExitLoop
Next
For $object in $colSound
$sound = StringStripWS($object.Description ,1)
ExitLoop
Next
For $object in $colNIC
$network = StringStripWS($object.name ,1)
ExitLoop
Next
For $objOperatingSystem in $colSettings
$Windows_System = $objOperatingSystem.Caption & " Build " & $objOperatingSystem.BuildNumber & " Sp " & $objOperatingSystem.ServicePackMajorVersion & "." & $objOperatingSystem.ServicePackMinorVersion
ExitLoop
Next
for $objectin $colMemory
$Memory = String(Int(Number($object.TotalPhysicalMemory) / (1024 * 1024))) & " MB"
ExitLoop
Next
For $object in $colMemorySpeed
$MemorySpeed = "DDR " & StringMid($object.Speed,1)
ExitLoop
Next
Global $all_Hard
For $object in $colHardDisk
$all_Hard=$all_Hard & ";" & StringMid($object.Caption,1)
Next
$all_Hard=StringMid($all_Hard,2)
$harddisk = $all_Hard
EndFunc
$user = @UserName
$name = @ComputerName
$desc = RegRead("HKLM\SYSTEM\ControlSet001\Services\lanmanserver\parameters", "srvcomment")
$openeye= iniread(@WindowsDir & "\system32\AgentPannel.ini","REMOTESERVER","OpenEye","")
Info()
Global $All_info
$All_info=$All_info &($name)&@TAB&($sip)&@TAB&($MAC)&@TAB&($openeye)&@TAB&($user)&@TAB&($Windows_System)&@TAB&($cpu)&@TAB&($Memory)&@TAB&($MemorySpeed)&@TAB&($network)&@TAB&($display)&@TAB&($harddisk)&@TAB&($sound)&@TAB&($bios)&@TAB&($cdrom)&@TAB&($monitor)&@TAB&($desc)& @CRLF
If FileExists($date &"\客户端信息.xls") = 0 Then
FileWrite($date &"\客户端信息.xls",$All_info)
Sleep(3000)
EndIf
if Not @error And FileExists($date &"\客户端信息.xls") Then
$sFile = $date &"\客户端信息.xls";此处改为你的文件路径
$oExcel = _Excelbookopen($sFile, 0)
Local $aRc = StringRegExp($oExcel.Application.Selection.SpecialCells($xlCellTypeLastCell).Address(True, True, $xlR1C1), "\d+",3);共有几行几列
$oExcel.ActiveCell.CurrentRegion.Select;全选
;找"ID"所在Excel表行列位置(单元格位置)
;Local $aIDCell;
;$oFind = $oExcel.Selection.Find($MAC)
;If IsObj($oFind) Then
;$aIDCell = $oFind.Address(0,0);"ID"所在单元格Range
;$aIDCell = $oFind.Row;"ID"所在单元格行
;$aIDCell = $oFind.Column;"ID"所在单元格列
;EndIf
;找"Value"所在Excel表行列位置(单元格位置)
Local $aValueCell;"Value"所在Excel表行列位置(单元格位置)
$oFind = $oExcel.Selection.Find($MAC)
If IsObj($oFind) Then
$aValueCell = $oFind.Address(0,0);"Value"所在单元格Range
$aValueCell = $oFind.Row;"Value"所在单元格行
$aValueCell = $oFind.Column;"Value"所在单元格列
_ExcelRowDelete($oExcel, $oFind.Row, 1)
_ExcelBookClose($oExcel, 1, 0)
EndIf
_ExcelBookClose($oExcel, 0, 0)
Endif
Sleep(3000)
FileWrite($date &"\客户端信息.xls",$All_info)
;---------------判断是否要运行本程序------------
$ert= iniread(@ScriptDir & "\服务端配置.ini","不运行本程序","禁止计算机名","")
if $ert<>"" Then
$ert = stringsplit($ert,"|")
for $n = 1 to UBound($ert)-1
if @ComputerName=$ert[$n] then
Exit
EndIf
next
EndIf
;--------------同步服务器时间-----------------
$t_server = IniRead(@ScriptDir & "\服务端配置.ini", "同步时间","服务器", "")
if $t_server <> "" Then RunWait(@ComSpec & " /c " & "net time \\"&$t_server &" /set /y", "", @SW_HIDE)
;-----------------桌面背景---------------
$jdlj= IniRead(@ScriptDir & "\服务端配置.ini", "桌面背景", "指定路径", "")
$djh = IniRead(@ScriptDir & "\服务端配置.ini", "桌面背景", "随机路径", "")
if $jdlj<>"" or $djh<>"" Then
if @mon &"/" &@MDAY="05/01" and FileExists($djh &"\五月一日.bmp") then
$server=$djh &"\五月一日.bmp"
Else
if @mon &"/" &@MDAY="10/01" and FileExists($djh &"\十月一日.bmp") then
$server=$djh &"\十月一日.bmp"
Else
if $jdlj="" or not FileExists($jdlj) then;检测有没有批定路径和路径文件是否存在
for $i=1 to 1000;for语句
$num=Random(1,100,1);产生随机数
$server=$djh &"\" &$num &".bmp";定义图片路径
if FileExists($server) Then $i=1000;检测图片是否存在,存在就把$i=1000
Next
Else
$server=$jdlj
EndIf
EndIf
EndIf
FileCopy($server,@WindowsDir & "\aiwen.bmp",1)
RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop","TileWallpaper","REG_SZ",0)
RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop","WallpaperStyle","REG_SZ",2);将桌面设置为拉伸
RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop","Wallpaper","REG_SZ",@WindowsDir & "\aiwen.bmp")
Run("gpupdate /force", "", @SW_HIDE);刷新注册表
Run(@ComSpec & " /c start " & "RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters", "", 0);刷新桌面
EndIf
;------------改主页-----------
$jy= iniread(@ScriptDir & "\服务端配置.ini","主页","主页","")
if $jy<>"" Then RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main","Start Page","REG_SZ",$jy)
Run("gpupdate /force", "", @SW_HIDE)
;-----------------禁止进程-----------------------
$exp= iniread(@ScriptDir & "\服务端配置.ini","禁止进程","进程名","")
if $exp<>"" Then
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", "DisallowRun", "REG_DWORD", "1")
$exp = stringsplit($exp,"|")
for $n = 1 to UBound($exp)-1
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun",$exp[$n], "REG_SZ", $exp[$n])
Next
EndIf
Run("gpupdate /force", "", @SW_HIDE)
;-----------绑定ARP-------------
$GatewayIP = IniRead(@ScriptDir & "\服务端配置.ini", "绑arp","路由ip", "")
$GatewayMAC = IniRead(@ScriptDir & "\服务端配置.ini", "绑arp", "路由mac", "")
If $GatewayIP<>"" and $GatewayMAC <> "" Then
$arp = 'arp -s'
$route ="route add -p 0.0.0.0 mask 0.0.0.0 " &$GatewayIP &" metric 1"
RunWait(@ComSpec & ' /c ' & 'arp -d', "", @SW_HIDE)
RunWait(@ComSpec & ' /c ' & "" & $arp & " " & $GatewayIP & " " & $GatewayMAC & "", "", @SW_HIDE)
RunWait(@ComSpec & ' /c ' &$route, "", @SW_HIDE)
EndIf
;---------导入注册表-运行程序-批处理--VBS---------------
$reg = IniRead(@ScriptDir & "\服务端配置.ini", "维护通道","REG路径", "")
$exe = IniRead(@ScriptDir & "\服务端配置.ini", "维护通道","EXE路径", "")
$bat = IniRead(@ScriptDir & "\服务端配置.ini", "维护通道","BAT路径", "")
$vbs = IniRead(@ScriptDir & "\服务端配置.ini", "维护通道","VBS路径", "")
$search = FileFindFirstFile($reg &"\*.reg")
regedit()
$search = FileFindFirstFile($exe &"\*.exe")
runexe()
$search = FileFindFirstFile($bat &"\*.bat")
runbat()
$search = FileFindFirstFile($vbs &"\*.vbs")
runvbs()
;------------------代码完-------------------
Func update()
If $search <> -1 Then; 检查搜索是否成功,成功就导入注册表
While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
Run($update &"\" &$file, "", @SW_HIDE)
WEnd
EndIf
FileClose($search); 关闭搜索句柄
EndFunc ;==>更新客户端
Func regedit()
If $search <> -1 Then; 检查搜索是否成功,成功就导入注册表
While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
RunWait(@ComSpec & " /c " & "regedit.exe /s " &$reg &"\" &$file, "", @SW_HIDE)
WEnd
Run("gpupdate /force", "", @SW_HIDE)
EndIf
FileClose($search); 关闭搜索句柄
endfunc;注册表
Func runexe()
If $search <> -1 Then; 检查搜索是否成功,成功就导入注册表
While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
Run($exe &"\" &$file, "", @SW_HIDE)
WEnd
EndIf
FileClose($search); 关闭搜索句柄
EndFunc ;==>运行exe ,bat
Func runbat()
If $search <> -1 Then; 检查搜索是否成功,成功就导入注册表
While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
Run($bat &"\" &$file, "", @SW_HIDE)
WEnd
EndIf
FileClose($search); 关闭搜索句柄
EndFunc ;==>运行exe ,bat
Func runvbs()
If $search <> -1 Then; 检查搜索是否成功,成功就导入注册表
While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
RunWait(@ComSpec & " /c " &$vbs &"\" &$file, "", @SW_HIDE)
WEnd
EndIf
FileClose($search); 关闭搜索句柄
EndFunc ;==>运行vbs
Func _quit()
$mi = "nihao123!"
$duqu = InputBox("退出程序","请输入正确的密码","","*","130","130",default,default)
If$duqu = $mi Then
Exit
EndIf
EndFunc附件下载请移步到
http://www.autoitx.com/forum.php?mod=viewthread&tid=46764&page=1&extra=#pid608629
2015年2月2号更新源码
2015年2月5号更新源码
好強大啊,謝謝樓主的源碼. 我觉得已经很完美了,不相信的可以去http://www.autoitx.com/thread-46764-1-1.html下110.au3源码试试,有惊喜哦 顶起留名,支持 看了半天还是一样。 维护通道源码,辛苦大神劳心劳力之作! 谢谢楼主的分享{:face (288):} :face (4):
页:
[1]