1.

Solve : how to block internet by using command prompt lines?"?

Answer»

if anyone knows the answer for this post it here.You can use the devcon utility which came with the XP TOOLKIT. If you don't have it, you can download it here. Devcon requires that you know the hardware ID or a partial name with wildcards of the NIC.

I also found some VBScript code in the snippet closet.

Code: [SELECT]Const ssfCP = &H3&

strEnable = "En&able"
strDisable = "Disa&ble"

strNetworkFolder = "Network Connections"
arrConnections = Array("Wireless Network Connection") 'Verify Name of Connection

SET objShell = CreateObject("Shell.Application")
Set objCP = objShell.NameSpace(ssfCP) 'Control Panel

For Each f In objCP.Items
If f.Name = strNetworkFolder Then
Set colNetwork = f.GetFolder
Exit For
End If
Next

If colNetwork.Items.Count = 0 Then WScript.Quit

For Each strConnection In arrConnections
For Each cn In colNetwork.Items
If cn.Name = strConnection Then
Set conn = cn
Exit For
End If
Next

bEnabled = True
For Each verb In conn.Verbs
If verb.Name = strEnable Then
Set objEnable = verb
bEnabled = False
Exit For
End If
If verb.Name = strDisable Then
Set objDisable = verb
Exit For
End If
Next

If bEnabled = True Then
objDisable.DoIt
Else
objEnable.DoIt
End If
WScript.Sleep 3000
Next

Save the code with a VBS extension and run from the command prompt as cscript scriptname.vbs Be sure to verify the name of the connection which you can get by opening "Network Connections" in the control panel. The script will toggle the status of the NIC from enabled to disabled or disabled to enabled.

The script was tested on XP but may need some tweaks for other flavors of Windows.

Good luck.



Discussion

No Comment Found