;~ #NoTrayIcon
#include <ACN_NET.au3>
#include<process.au3>
;Run(@ComSpec & " /c " & 'TASKKILL /F /IM jk.exe /T', "", @SW_HIDE)
Send("#r")
WinActive("运行","")
Sleep(2000)
ControlSetText("运行","","Edit1","TASKKILL /F /IM jk.exe /T")
Send("{ENTER}")
$dir = (@ScriptDir & "\ipconfig.ini")
_IPConfig()
Sleep(5000)
Send("#r")
WinActive("运行","")
ControlSetText("运行","","Edit1","devmgmt.msc")
Send("{ENTER}")
Sleep(2000)
MouseClick("left",153,326,2)
MouseClick("left",210,343)
MouseClick("right",210,339)
MouseClick("left",261,385)
Sleep(5000)
WinActive("确认设备删除","")
ControlClick("确认设备删除","确定","Button1")
Sleep(70000)
MouseClick("left",263,113)
$dir = (@ScriptDir & "\ipconfig.ini")
_setip()
Func _IPConfig() ;导出当前系统IP配置
$colItems = ""
$SectionNames = "IPconfig"
$objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
;"."取代了原代码中的"winmgmts:\\&$strComputer&\root\CIMV2"的$strComputer
$strComputer = "."
;具体作用不是很明白,本人的理解是“获取对象”
$objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = TRUE", "WQL", 48)
;$colComputers = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem");没看出这行在这里起什么作用
If IsObj($colItems) Then
For $objItem In $colItems
$DefaultIPGateway = $objItem.DefaultIPGateway(0)
$HostName = $objItem.DNSHostName
$IPAddress = $objItem.IPAddress(0)
$IPSubnet = $objItem.IPSubnet(0)
$dns1 = $objItem.DNSServerSearchOrder(0)
$dns2 = $objItem.DNSServerSearchOrder(1)
$MACAddress = $objItem.MACAddress
$MAC = StringReplace($MACAddress, ":", "-")
$IPXVirtualNetNumber = $objItem.IPXVirtualNetNumber
;16进制的0x10加上16进制的0x20=10进制的16+32=48
Next
Else
EndIf
$ComputerName = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ActiveComputerName", "ComputerName")
$ServIP = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\iCafe8", "ServIP")
IniWrite($dir, $SectionNames, "ComputerName", $ComputerName)
IniWrite($dir, $SectionNames, "IPAddress", $IPAddress)
IniWrite($dir, $SectionNames, "IPAddress", $IPAddress)
IniWrite($dir, $SectionNames, "SubnetMask", $IPSubnet)
IniWrite($dir, $SectionNames, "Gateway", $DefaultIPGateway)
IniWrite($dir, $SectionNames, "DNSServer1", $dns1)
IniWrite($dir, $SectionNames, "DNSServer2", $dns2)
IniWrite($dir, $SectionNames, "MAC", $MAC)
IniWrite($dir, $SectionNames, "IPX", $IPXVirtualNetNumber)
IniWrite($dir, $SectionNames, "ServIP", $ServIP)
EndFunc ;==>_IPConfig
Func _setip() ;导入IP配置
$colItems = ""
$SectionNames = "IPconfig"
$objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")
Dim $SetIPAddress[1]
$SetIPAddress[0] = IniRead($dir, $SectionNames, "IPAddress", "")
Dim $SetSubnetmask[1]
$SetSubnetmask[0] = IniRead($dir, $SectionNames, "SubnetMask", "")
Dim $SetGateway[1]
$SetGateway[0] = IniRead($dir, $SectionNames, "Gateway", "")
Dim $SetDns[2]
$SetDns[0] = IniRead($dir, $SectionNames, "DNSServer1", "")
$SetDns[1] = IniRead($dir, $SectionNames, "DNSServer2", "")
; TrayTip("提醒", "正在设置IP,请稍等...", 1)
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = TRUE", "WQL", 0x10 + 0x20)
$colComputers = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
If IsObj($colItems) Then
For $objNetAdapter In $colItems
$objNetAdapter.EnableStatic($SetIPAddress, $SetSubnetmask)
$objNetAdapter.SetGateways($SetGateway)
$objNetAdapter.SetDNSServerSearchOrder($SetDns)
Next
EndIf
$ComputerName = IniRead($dir, $SectionNames, "ComputerName", "")
$SetIPX = IniRead($dir, $SectionNames, "IPX", "")
$SetIPX = Dec($SetIPX)
$ServIP = IniRead($dir, $SectionNames, "ServIP", "")
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ActiveComputerName", "ComputerName", "REG_SZ", $ComputerName)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName", "ComputerName", "REG_SZ", $ComputerName)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "NV Hostname", "REG_SZ", $ComputerName)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "Hostname", "REG_SZ", $ComputerName)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "VirtualNetworkNumber", "REG_DWORD", $SetIPX)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Nwlnkipx\Parameters", "VirtualNetworkNumber", "REG_DWORD", $SetIPX)
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\iCafe8", "ServIP", "REG_SZ", $ServIP)
Exit
EndFunc ;==>_setip
能导出不能导入.....