防止孩子沉迷,限制孩子上网时间的方法(3)
时间:2013-12-19 15:29来源:panpan.org 作者:大红鱼 点击:次
、星期五,这样,每到星期三和星期五的16:30,计算机就会自动为我们断开网络。 同样将连接网络.bat添加到计划任务中,让计算机在每周星期三和星期五
”、“星期五”,这样,每到星期三和星期五的16:30,计算机就会自动为我们断开网络。
同样将“连接网络.bat”添加到计划任务中,让计算机在每周星期三和星期五的14:00自动执行“连接网络.bat”。
怎么样?连接或断开网络的事情再也不用我们自己去管了吧
(如果每天连接或断开网络的时间不同,则可以分别为每天设置计划任务)!
断开网络bat
@echo off
00:00 Rasdial %MyConnection% /disconnect
以上存为BAT文件。时间间改一下就可以了,分别是时和分
定时断开网络连接(BAT批处理文件设计参考)
参考一
http://zhidao.baidu.com/question/115003887.html
提问:用批处理运行程序“xx.exe”30分钟后,断开网络连接。
注意!要后台运行!在断开网络连接时不要回显!!
我以前做了一个能后台运行,但是在断开网络连接时又弹出cmd对话框!
最佳答案
'vbs
GetObject("", "WScript.Shell").Run """" & "xx.exe" & """"
WSH.Sleep 1000 * 60 * 30
ChangeConnectionStatus False
Sub ChangeConnectionStatus(ByVal bEnable)
Const CONTROL_PANEL = &H3&
Const NET_CONNECTIONS = "网络连接"
Const CONNECTION = "本地连接"
Const ENABLE = "启用(&A)"
Const DISABLE = "停用(&B)"
Dim oShell
Dim oControlPanel, oControlItem
Dim oNetConnections, oConnectionItem, oConnection
Dim oVerbItem, oVerb
Dim bCurrentEnabled
Set oShell = CreateObject("Shell.Application")
Set oControlPanel = oShell.Namespace(CONTROL_PANEL)
For Each oControlItem in oControlPanel.Items
If oControlItem.Name = NET_CONNECTIONS Then
Set oNetConnections = oControlItem.GetFolder
Exit For
End If
Next
For Each oConnectionItem In oNetConnections.Items
If oConnectionItem.Name = CONNECTION Then
Set oConnection = oConnectionItem
Exit For
End If
Next
For Each oVerbItem In oConnection.Verbs
If oVerbItem.Name = ENABLE Then
bCurrentEnabled = False
Set oVerb = oVerbItem
Exit For
ElseIf oVerbItem.Name = DISABLE Then
bCurrentEnabled = True
Set oVerb = oVerbItem
Exit For
End If
Next
'If Not (bCurrentEnabled And bEnable) Then
If bCurrentEnabled <> bEnable Then
oVerb.DoIt
Do
For Each oVerbItem In oConnection.Verbs
If (bCurrentEnabled And (oVerbItem.Name = ENABLE)) Or _
((Not bCurrentEnabled) And (oVerbItem.Name = DISABLE)) Then _
Exit Do
Next
WSH.Sleep 100
Loop
End If
Set oVerb = Nothing: Set oVerbItem = Nothing
Set oConnection = Nothing: Set oConnectionItem = Nothing: Set oNetConnections = Nothing
Set oControlItem = Nothing: Set oControlPanel = Nothing
Set oShell = Nothing
End Sub
参考二
源自于:
http://www.qikan.com.cn/Article/dakj/dakj201009/dakj201009278.html
设计BAT批处理文件
首先我们用记事本建立一个.bat批处理文件,其内容如下:
@echo off
rem 定义循环间隔时间:
set secs=120
echo.
echo ============================================
echo == 此脚本用于计算机共享访问达到上限后使用 ==
echo ==运行脚本后会自动断开一些访问连接 ==
echo ==每%secs%秒种进行查询,并执行清除命令 ==
echo ============================================
echo.
nul || goto :error
:begin
set clear=0
echo.
for /f "tokens=1,2" %%i in ('net session ^| find ""') do (
nul 2>&1
set clear=1
echo %time:~0,8% 清除访问来源: %%i [%%j]
------分隔线----------------------------