Sign in to follow this  
Followers 0
Borje

Need help with Children internet control

15 posts in this topic

Hello

Is there anybody here that have some solution to restrict the internet use for children

example from monday to thursday start time 14:00 endtime 22:00 and

from Friday and saturday 08:00 to 23:00 and sunday from 08:00 to 22:00

and when the time not match they have not Internet and have this to work in real time

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Yes this would be easy to code. Set up a loop and query the time and day of week using the below macros. If the time and day equals the prohibited time search for the process "iexplore.exe", "Opera.exe" etc. and then kill it using "ProcessClose "

Edit: Let's be real here though. Any kid worth his salt could figure out what is going on and kill your program using window task manager.

@MSEC
 Milliseconds value of clock.  Range is 00 to 999
 
@SEC
 Seconds value of clock.  Range is 00 to 59
 
@MIN
 Minutes value of clock.  Range is 00 to 59
 
@HOUR
 Hours value of clock in 24-hour format.  Range is 00 to 23
 
@MDAY
 Current day of month.  Range is 01 to 31
 
@MON
 Current month.  Range is 01 to 12
 
@YEAR
 Current four-digit year  
@WDAY
 Numeric day of week.  Range is 1 to 7 which corresponds to Sunday through Saturday.  
@YDAY
 Current day of year.  Range is 1 to 366 (or 365 if not a leap year)
Edited by picea892

Share this post


Link to post
Share on other sites

I am currently working on a Parental Controls Program and will post it when complete.

In the meantime you could always use windows scheduler to run one of the following dependant on your Operating system:

(scripts written by others)

For XP: you will need Devcon from microsoft. put it in the same location as the script is run.

#include <GUIConstantsEx.au3>
Global Const $DEVCON = @ScriptDir & "\devcon.exe"
XPNETDISABLE ()

;XP DISABLE NETWORK ADAPTER
FUNC XPNETDISABLE ()
ShellExecute($DEVCON, "disable ms_pschedmp", "", "", @SW_HIDE)
ENDFUNC

;XP ENABLE NETWORK ADAPTER
FUNC XPNETENABLE ()
ShellExecute($DEVCON, "enable ms_pschedmp", "", "", @SW_HIDE)
ENDFUNC

For Vista:

;  $iFlag = 0 ;Disable network interface
;  $iFlag = 1 ;Enable network interface
_ToggleNetworkInterface('local area connection', 1)


Func _ToggleNetworkInterface($strNetwork, $iFlag = 1)
    Local $wbemFlagReturnImmediately = 0x10
    Local $wbemFlagForwardOnly = 0x20
    Local $strComputer = "localhost"

    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    If IsObj($colItems) Then
        For $objItem In $colItems           
            If $objItem.NetConnectionID = $strNetwork Then
                If $iFlag = 0 And $objItem.NetEnabled = True Then
                    $objItem.Disable
                ElseIf $iFlag = 1 And $objItem.NetEnabled = False Then
                    $objItem.Enable
                EndIf
                ExitLoop
            EndIf
        Next
    Else
        MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_NetworkAdapter")
    EndIf
EndFunc

Hope this helps

Gingerbloke

Share this post


Link to post
Share on other sites

Hi Gingerbloke

Thanks for your examples i have try the example for windows XP but

that not working. I have the Devcon.exe for 32 bit is that more i have

to do?

Share this post


Link to post
Share on other sites

I test this and it works to Turn off and turn on the internet but not the best way I think.

_RunDOS("ipconfig /release") ;Turn off internet

_RunDOS("ipconfig /renew") ; Turn on Internet

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Borje,

I have tried the XP code on 3 of my systems and it works on them. They are using wired and wireless hardware and all turn off within a few seconds.

I know I may be teaching you to 'Suck Eggs' but have you tried compiling it before running the .exe?

The only other thing I can suggest is checking if your Network device is identified as such. The below script should tell you if it finds your device. (it's someone else's script I have slightly modified).

Dim $aNetworkInfo
$cI_CompName = @ComputerName
Global  $wbemFlagReturnImmediately = 0x10, _
        $wbemFlagForwardOnly = 0x20
$lan = 0
_ComputerGetNetworkCards($aNetworkInfo)
$networkcard = $aNetworkInfo[0][0]

For $i = 1 to $aNetworkInfo[0][0]
    If StringInStr ($aNetworkInfo[$i][19], "Local Area Connection") And StringInStr ($aNetworkInfo[$i][0], "Ethernet") Then
        ;MsgBox (0, "", $aNetworkInfo[$i][0] & @CRLF & $aNetworkInfo[$i][19])
        MsgBox (0, "", $aNetworkInfo[$i][4]) ; show the network card name 
        $lan = 1
    ElseIf StringInStr ($aNetworkInfo[$i][19], "Wireless Network Connection") And StringInStr ($aNetworkInfo[$i][0], "WLAN") Then
        MsgBox (0, "", $aNetworkInfo[$i][0] & @CRLF & $aNetworkInfo[$i][19])
        $lan = 1
    ElseIf StringInStr ($aNetworkInfo[$i][0], "Ethernet") And $aNetworkInfo[$i][19] <> "" And Not StringInStr ($aNetworkInfo[$i][0], "1394") Then
        MsgBox (0, "", $aNetworkInfo[$i][0] & @CRLF & $aNetworkInfo[$i][19])
        $lan = 1
    EndIf
Next

If $lan = 1 Then
    MsgBox (0, "", "Yes, You have a network card installed !")
ElseIf $lan = 0 Then
    MsgBox (0, "", "No, No network cards installed !")
EndIf

Func _ComputerGetNetworkCards(ByRef $aNetworkInfo)
    Local $colItems, $objWMIService, $objItem
    Dim $aNetworkInfo[1][34], $i = 1

    $objWMIService = ObjGet("winmgmts:\\" & $cI_Compname & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    If IsObj($colItems) Then
        For $objItem In $colItems
            ReDim $aNetworkInfo[UBound($aNetworkInfo) + 1][34]
            $aNetworkInfo[$i][0] = $objItem.Name
            $aNetworkInfo[$i][1] = $objItem.AdapterType
            $aNetworkInfo[$i][2] = $objItem.AdapterTypeId
            $aNetworkInfo[$i][3] = $objItem.AutoSense
            $aNetworkInfo[$i][4] = $objItem.Description
            $aNetworkInfo[$i][5] = $objItem.Availability
            $aNetworkInfo[$i][6] = $objItem.ConfigManagerErrorCode
            $aNetworkInfo[$i][7] = $objItem.ConfigManagerUserConfig
            $aNetworkInfo[$i][8] = $objItem.CreationClassName
            $aNetworkInfo[$i][9] = $objItem.DeviceID
            $aNetworkInfo[$i][10] = $objItem.ErrorCleared
            $aNetworkInfo[$i][11] = $objItem.ErrorDescription
            $aNetworkInfo[$i][12] = $objItem.Index
            $aNetworkInfo[$i][13] = $objItem.Installed
            $aNetworkInfo[$i][14] = $objItem.LastErrorCode
            $aNetworkInfo[$i][15] = $objItem.MACAddress
            $aNetworkInfo[$i][16] = $objItem.Manufacturer
            $aNetworkInfo[$i][17] = $objItem.MaxNumberControlled
            $aNetworkInfo[$i][18] = $objItem.MaxSpeed
            $aNetworkInfo[$i][19] = $objItem.NetConnectionID
            $aNetworkInfo[$i][20] = $objItem.NetConnectionStatus
            $aNetworkInfo[$i][21] = $objItem.NetworkAddresses(0)
            $aNetworkInfo[$i][22] = $objItem.PermanentAddress
            $aNetworkInfo[$i][23] = $objItem.PNPDeviceID
            $aNetworkInfo[$i][24] = $objItem.PowerManagementCapabilities(0)
            $aNetworkInfo[$i][25] = $objItem.PowerManagementSupported
            $aNetworkInfo[$i][26] = $objItem.ProductName
            $aNetworkInfo[$i][27] = $objItem.ServiceName
            $aNetworkInfo[$i][28] = $objItem.Speed
            $aNetworkInfo[$i][29] = $objItem.Status
            $aNetworkInfo[$i][30] = $objItem.StatusInfo
            $aNetworkInfo[$i][31] = $objItem.SystemCreationClassName
            $aNetworkInfo[$i][32] = $objItem.SystemName
            $aNetworkInfo[$i][33] = __StringToDate($objItem.TimeOfLastReset)
            $i += 1
        Next
        $aNetworkInfo[0][0] = UBound($aNetworkInfo) - 1
        If $aNetworkInfo[0][0] < 1 Then
            SetError(1, 1, 0)
        EndIf
    Else
        SetError(1, 2, 0)
    EndIf
EndFunc ;_ComputerGetNetworkCards

Func __StringToDate($dtmDate)
    Return (StringMid($dtmDate, 5, 2) & "/" & _
            StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
            & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc ;__StringToDate Function created by SvenP Modified by JSThePatriot

I have been running 'ipconfig' for my program but one computer lost network connection permanently that is why I moved over to the above scripts. I cannot be sure if it was the commands or a specific computer issue so it might work fine for you. One problem I found with ipconfig was that if a program was already accessing the internet when the cut-off time was reached, I had to terminate the process because it could still access the internet for quite a while after it should have stopped. This drove my kids mad when their screen just cleared.

I am still working on my program so if you don't need it for a week, I will post it soon.

Gingerbloke

Edited by gingerbloke

Share this post


Link to post
Share on other sites

Yes Gingerbloke

It was compiled but not working.

I test your last code and that found my nic card without any problem..

Share this post


Link to post
Share on other sites

@gingerbloke, You're assuming that the OP has an english return value in your last post, and that the user has access permissions to WMI ( One of the reasons I despise it ).


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

@gingerbloke, You're assuming that the OP has an english return value in your last post, and that the user has access permissions to WMI ( One of the reasons I despise it ).

Good points, I am used to using English configurations and to be honest, I have no idea what sort of changes other language settings have on a system (other than keyboard layout, times etc). All I can suggest is checking the Devcon syntax for your particular systems setup.

Regarding WMI, most systems I have come across allow it and luckily, on this occassion, the system was OK with it. I do not have a script for checking the network without using WMI.

Borje,

It may help if you can check the devcon commands for your language settings and if possible, adjust the command accordingly. Sorry I cannot help with this but I just went to the Swedish language site for Microsoft and Posted Image sorry to say, I do not understand the languagePosted Image

Please let me know if you find out that the command is different.

All the best

Gingerbloke

Share this post


Link to post
Share on other sites

You could always give your kids their own account on the computer which is a good idea anyways and give them a normal user not an admin. Then just set the ip address on the computer to something bogus so then you wouldn't beable to connect to anything. This is easily done with command prompt too.

RunWait(@ComSpec & " /c " & "netsh interface ip set address ""Local Area Connection"" static 5.3.2.1 255.0.0.0 5.3.1.1", "", @SW_HIDE)
RunWait(@ComSpec & " /c " & "netsh interface ip set dns ""Local Area Connection"" static 3.4.5.2 primary", "", @SW_HIDE)

of course you would need to make sure to change Local Area Connection to whatever you use as your NIC which is easily found out by going to control panel then going to network connections. To change it back to dhcp you would just do

RunWait(@ComSpec & " /c " & "netsh interface ip set address ""Local Area Connection"" dhcp", "", @SW_HIDE)
RunWait(@ComSpec & " /c " & "netsh interface ip set dns ""Local Area Connection"" dhcp", "", @SW_HIDE)

Share this post


Link to post
Share on other sites

Hello Onican or someone else i have try this 2 examples but not have that to work, what I am doing wrong?

RunWait(@ComSpec & " /c " & "netsh interface ip set address ""Local Area Connection"" static 5.3.2.1 255.0.0.0 5.3.1.1", "", @SW_HIDE)

RunWait(@ComSpec & " /c " & "netsh interface ip set dns ""Local Area Connection"" static 3.4.5.2 primary", "", @SW_HIDE)

Share this post


Link to post
Share on other sites

I have it to work now but it not works for another account only Administrator account in windows xp home

what to do for have it to work with another account?

Share this post


Link to post
Share on other sites

Yes thats because only administrators have rights to change network settings. Isn't that the point of the script you want? to restrict your children's internet access? You would give your children normal account not admin ones. Then you could have a script running as the administrator run at the times you want to either enable or disable the network connections. That why they cant access the internet and cant turn it back on.

Share this post


Link to post
Share on other sites

Hi and thanks Onichan

Yes the idea is good but if I have a program running that check the time when children have right to user internet that is not good

at their accound stop this change to the network. Is that anyway to change the right for the childrens account to have access to

the network?

In other way I must first login as administrator and the close internet every time children use the computer...

Is that anyone here have some tips? I have Windows XP Home

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Well I was bored and used the _Service.udf written by arcker and modified by spudw2k to make something that should work. You will need to download that for this to work and put it in the same directory as this script while you compile this one. I have not tested it so no guarantee. Now it creates a service that runs in the background that should either enable or disable the NIC according to the times you specified in your first post. You can modify it to what you need. You will need to log on as an administrator to set it up at first. First compile the script then put it somewhere that you plan on keeping it because it must stay there while its running. Then just double click it and it should bring up a couple prompts to install then start the service.

#include<_Service.au3>
#include<Misc.au3>
#NoTrayIcon
#RequireAdmin
#AutoIt3Wrapper_Change2CUI=y
If Not @Compiled Then Exit
If Not _Singleton(@ScriptName) Then
    If $cmdline[0] > 0 Then
        If $cmdline[1] = "stop" Or StringRight($cmdline[1], 1) = "s" Then

        Else
            ConsoleWrite("Process is running.")
            Exit
        EndIf
    Else
        ConsoleWrite("Process is running.")
        Exit
    EndIf
EndIf

$Servicename = StringLeft(@ScriptName, StringInStr(@ScriptName, ".") - 1)
$sServiceName = $Servicename
If $cmdline[0] > 0 Then
    Switch $cmdline[1]
        Case "install", "-i", "/i"
            InstallService()
        Case "remove", "-u", "/u", "uninstall"
            RemoveService()
        Case "run", "-r", "/r", "start"
            _SelfRun($sServiceName, "start")
        Case "stop", "-s", "/s"
            _SelfRun($sServiceName, "stop")
        Case Else
            ConsoleWrite(" - - - Help - - - " & @CRLF)
            ConsoleWrite(" Service Example Params : " & @CRLF)
            ConsoleWrite(" -i : Installs service" & @CRLF)
            ConsoleWrite(" -u : Removes service" & @CRLF)
            ConsoleWrite(" -r : Runs the service" & @CRLF)
            ConsoleWrite(" -s : Stops the service" & @CRLF)
            ConsoleWrite(" - - - - - - - - " & @CRLF)
            Exit
            ;start service.
    EndSwitch
    _Service_Init($sServiceName)
Else
    If Not _ServiceExists("", $sServiceName) Then
        If MsgBox(20, "Service Not Installed.", "Would you like to install this service?" & @CRLF & $sServiceName) = 6 Then
            If InstallService() Then
                If MsgBox(4, $sServiceName, "Service Installed Successfully." & @CRLF & "Do you wish to start the process?") = 6 Then _SelfRun($sServiceName, "start")
            EndIf
        Else
            Exit
        EndIf
    Else
        _Service_Init($sServiceName)
    EndIf
EndIf

Func _Main()
    Local $State = True
    While 1
        If $State = False Then
            If @WDAY >= 2 And @WDAY <= 5 Then
                If @HOUR >= 14 And @HOUR <= 22 Then
                    _Enable()
                    $State = True
                EndIf
            ElseIf @WDAY = 6 Or @WDAY = 7 Then
                If @HOUR >= 08 And @HOUR <= 23 Then
                    _Enable()
                    $State = True
                EndIf
            ElseIf @WDAY = 1 Then
                If @HOUR >= 08 And @HOUR <= 22 Then
                    _Enable()
                    $State = True
                EndIf
            EndIf
        Else
            If @WDAY >= 2 And @WDAY <= 5 Then
                If @HOUR < 14 Or @HOUR > 22 Then
                    _Disable()
                    $State = False
                EndIf
            ElseIf @WDAY = 6 Or @WDAY = 7 Then
                If @HOUR < 08 Or @HOUR > 23 Then
                    _Disable()
                    $State = False
                EndIf
            ElseIf @WDAY = 1 Then
                If @HOUR < 08 Or @HOUR > 22 Then
                    _Disable()
                    $State = False
                EndIf
            EndIf
        EndIf
        Sleep(60000)
    WEnd
EndFunc ;==>_Main

Func _Enable()
    RunWait(@ComSpec & " /c " & "netsh interface ip set address ""Local Area Connection"" dhcp", "", @SW_HIDE)
    RunWait(@ComSpec & " /c " & "netsh interface ip set dns ""Local Area Connection"" dhcp", "", @SW_HIDE)
EndFunc ;==>_Enable

Func _Disable()
    RunWait(@ComSpec & " /c " & "netsh interface ip set address ""Local Area Connection"" static 5.4.3.1 255.0.0.0 8.2.6.3 1", "", @SW_HIDE)
    RunWait(@ComSpec & " /c " & "netsh interface ip set dns ""Local Area Connection"" static 6.7.8.9 primary", "", @SW_HIDE)
EndFunc ;==>_Disable

Func InstallService()
    ConsoleWrite("Installing Service, Please Wait" & @CRLF)
    _CreateService("", $sServiceName, $Servicename, '"' & @ScriptFullPath & '"')
    If @error Then
        ConsoleWrite("Problem Installing Service, Error number is " & @error & @CRLF & " message : " & _WinAPI_GetLastErrorMessage())
        Return 0
    Else
        ConsoleWrite("Installation of Service Successful")
    EndIf
    Return 1
    Exit
EndFunc ;==>InstallService

Func RemoveService()
    _StopService("", $sServiceName)
    _DeleteService("", $sServiceName)
    If Not @error Then ConsoleWrite("Service Removed Successfully" & @CRLF)
    Exit
EndFunc ;==>RemoveService

Func _SelfRun($Servicename, $action)
    $sCmdFile = 'sc ' & $action & ' "' & $Servicename & '"' & @CRLF & 'del ' & @TempDir & '\runsvc.bat'
    FileWrite(@TempDir & "\runsvc.bat", $sCmdFile)
    Run(@TempDir & "\runsvc.bat", @TempDir, @SW_HIDE)
    Exit
EndFunc ;==>_SelfRun

I put in all the If statements because I didn't want to just keep disabling it every 60 seconds if it wasnt suppose to have internet access. A very important thing you should know is that while this service is running if its working then that computer will not have any internet access reguardless of the user during the times you specified. Just remember that if you plan on having multiple people use the computer. You could always stop the service and then say have a script on your desktop just for enabling the NIC again to use the computer. Then when your done just restart the service and it should disable the NIC if its past that time. Also remember if the account the children is using has admin rights they can easily get around this.

Edited by Onichan

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0