postgres wrote:
I love this idea - my kids are always doing stuff they should not be doing on the computers after school. Would it be possible to just block access to the internet without the USB key being installed? That way they could still play games, use Word and stuff for school, but not get online. I would pay for tested code either way (total lock or just internet) that would run at startup and accomplish this.
Put this in front, (it selects the default connection)
Code:
SetWorkingDir, %A_Temp%
FileDelete, NetChange.tmp
FileDelete, NetChange1.tmp
FileDelete, NetChange.bat
RunWait, %Comspec% /c netsh interface show interface >>NetChange.tmp, , Hide
Loop, Read, NetChange.tmp
{
StringReplace, Delimiter, A_LoopReadLine, Dedicated, §, UseErrorLevel
If ErrorLevel = 0
Continue
Loop, Parse, Delimiter, §
{
If A_LoopField not contains able
{
StringReplace, LAN_Name, A_LoopField, %A_Space%%A_Space%, , All
FileAppend, %LAN_Name%|, NetChange1.tmp
LAN_Cnt++
}
}
}
FileDelete, NetChange.tmp
FileRead, Var, NetChange1.tmp
StringTrimRight, Var, Var, 1
FileAppend, %Var%, NetChange.tmp
FileRead, LAN, NetChange.tmp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ICCE_size := 8
GWL_HINSTANCE := -6
WM_USER := 0x400
ICC_INTERNET_CLASSES := 0x800
WS_CHILD := 0x40000000
WS_VISIBLE := 0x10000000
IPM_GETADDRESS := WM_USER + 102
IPM_SETADDRESS := WM_USER + 101
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Gui +LastFound
GuiID := WinExist()
Gui, Font, cBlue
Gui, Color, Black
Gui, Font, s10
Gui, Add, GroupBox, x15 y15 w293 h120, Select your Defualt Network Adapter name.
Gui, Font, cLime
Gui, Add, Text, x25 y49 w70 h20, LAN Name:
Gui, Add, DropDownList, Choose1 R%LAN_Cnt% vLAN_Name x95 y45 w202 h25, %LAN%
;Gui, Add, Checkbox, x25 y85 gDHCP vDHCP, DHCP (Obtain an IP address automatically)
Gui, Add, Picture, x15 y151 Icon89, C:\WINDOWS\system32\SHELL32.dll
Gui, Add, Picture, x278 y151 Icon89, C:\WINDOWS\system32\SHELL32.dll
Gui, Font, s16
Gui, Add, Button, x62 y148 w200 h35 Default vButton, APPLY
;GuiControl, Disable, Button
Gui, Show, Center h195 w325, NetChange
return
ButtonApply:
GuiControlGet, LAN_Name, , ComboBox1
Gui, Submit
put this in someplace to toggle on and off the DNS
Code:
Run,
(LTrim Join`s
%comspec% /c netsh interface ip set dns
Name="%LAN_Name%"
Source=Static
Addr=208.67.222.222 ; opendns.org (you should set up an account anyways to filter bad stuff from youre house any way..) set it to 127.0.0.1 for no internet...
)
,,Hide
Untested... (the Static flag on the last part may conflict with your DHCP stuff..)
If so,
to turn back to DHCP.. (if the DNS only change does not work)
Code:
RunWait,
(LTrim Join`s
%comspec% /c netsh interface ip set address
Name="%LAN_Name%"
Source=DHCP
)
,,Hide
Run,
(LTrim Join`s
%comspec% /c netsh interface ip set dns
Name="%LAN_Name%"
Source=DHCP
)
,,Hide
if the DNS only one does not work, and you have to set a static IP as well, use this..
Code:
random, rand, 10, 99, NewSeed RunWait,
(LTrim Join`s
%comspec% /c netsh interface ip set address
Name="%LAN_Name%"
Source=Static
Addr=192.168.1.%rand% ;your ip range may be different.. only use %rand% if you have a small network.. For big networks or if your router uses 10-99<most start at 100>, just enter and IP that you know is free.
Mask=255.255.255.0
Gateway=192.168.1.1 ;or whatever you use
GWmetric=0
)
,,Hide
That's just rough code from one of my programs, pm me if you need help.. I store the LAN_Name in an ini so you do not have to select it every time.
BTW, I have seen viruses write a reg value that effects the DNS for ALL network connections, but I do not remember and I need to research it.. If someone knows, PM me or post here. It would be much easier to toggle via a regwrite.
