批处理高手请来帮忙

来源:百度知道 编辑:UC知道 时间:2024/05/28 02:20:35
请高手帮我做个批处理。我有个软件x.exe 不能连接网络使用.能不能帮我写个批处理运行x.exe时间禁用网络连接。当停止使用x.exe时又自动启用网络连接。说用防火墙的请不要留言了。

'"&@cls&cscript -nologo -e:vbs "%~f0" false&x.exe&start cscript -nologo -e:vbs "%~f0" true&goto :eof
Option Explicit
ChangeConnectionStatus WSH.Arguments(0)

Sub ChangeConnectionStatus(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 oN