单位最近要上新设备,说是每个人一个ip以后上级要绑定ip和个人,会查看个人上网行为。
头疼的是,单位的ip很乱,而且涉及很多人共用一台电脑的问题,怎么能让他们在不用学会如何改ip的情况下就能在上网时把ip改成自己的,离开电脑时把ip改成不能用的呢?
最终我想了一个笨办法,就是用ip切换的功能实现。
当要上网时,运行这个文件,点击上网,把ip设置成个人的ip,然后要离开电脑时,再把ip设置成一个根本没办法用的一串1的ip地址就行了。
呵呵,很笨吧?不过好用。代码如下:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$IP = GUICreate("上网保证器", 341, 79, 192, 132)
$Button1 = GUICtrlCreateButton("上网", 24, 16, 129, 49)
$Button2 = GUICtrlCreateButton("离开", 183, 16, 129, 49)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
shangwang()
Exit
Case $Button2
likai()
Exit
EndSwitch
WEnd
Func likai()
$IP = "01.01.01.01"
$zwym = "01.01.01"
$router = "01.01.01.01"
$dns = "01.01.0101"
;修改IP,dns,路由为不能用的号段
RunWait('netsh interface ip set address name = "本地连接" source = static addr = ' & $IP & ' mask = ' & $zwym & ' gateway = ' & $router & ' gwmetric = 0', "c:\windows\system32", @SW_HIDE)
RunWait('netsh interface ip set dns name = "本地连接" source = static addr = ' & $dns & ' register = PRIMARY', "c:\windows\system32", @SW_HIDE)
EndFunc
Func shangwang()
$IP = "个人ip"
$zwym = "255.255.255.0"
$router = "单位路由ip"
$dns = "单位的dns"
;修改IP,dns,路由为可用号码,如个人ip写192.168.1.2,单位路由ip写192.168.1.1,单位dns写当地网通的dns
RunWait('netsh interface ip set address name = "本地连接" source = static addr = ' & $IP & ' mask = ' & $zwym & ' gateway = ' & $router & ' gwmetric = 0', "c:\windows\system32", @SW_HIDE)
RunWait('netsh interface ip set dns name = "本地连接" source = static addr = ' & $dns & ' register = PRIMARY', "c:\windows\system32", @SW_HIDE)
EndFunc
到这里写完了,但是,有一个小问题,就是这玩意自动关闭很慢,不知道为什么,反正代码是抄的,问我我也看不懂,总之,大约十五六个数之内肯定可以退出的。就是搞不懂。回头再研究吧。呵呵。写完拉倒。