-
[RESOLVED] Can I Dissable Internet Connection With VB?
Hello. Im making some program to make my computer easier for use. I would like to know if I can disable the internet connection using VB code. If Its possible, then it will be nice if you show me how.
I got a modem and a router. Got no ideas what details exactly you need but any help will help.
Thanks.
-
Re: Can I Dissable Internet Connection With VB?
How is disabling the internet connection making the computer easier to use? If someone thinks the internet is complicated they don't have to use it. There may be an API to disable the LAN connection, but again, I don't think this is a good approach.
-
Re: Can I Dissable Internet Connection With VB?
Why would want to use a VB program to disable the Internet when all you have to do is flip the switch on the back of the modem or just pull the cable out of the PC.
If you are on DialUp then just don't dial in.
-
Re: Can I Dissable Internet Connection With VB?
For dial-up but I have not tested it...
Code:
Const Internet_Autodial_Force_Unattended As Long = 2
Public Declare Function InternetAutodial Lib "wininet.dll" (ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
Public Declare Function InternetAutodialHangup Lib "wininet.dll" (ByVal dwReserved As Long) As Long
Private Sub Disconnect()
Dim lResult As Long
lResult = InternetAutodialHangup(0&)
End Sub
-
Re: Can I Dissable Internet Connection With VB?
danecook21: I dont want others to use the internet on my computer in particular times each day. Beside that, I need to turn it off because the internet in other computer will work faster.
jmsrickland: Good question. Its because I need it to turn off automaticly when im not at home and I want it to be part of my new program.
dee-u: I cant understand how it works. Can you specify more details please?
Thanks.
-
Re: Can I Dissable Internet Connection With VB?
to turn off broadband internet you would need to disable your network connection
note dee-u solution only for dial up type connection, as he says
another possibility is to change the proxy settings to a non existent proxy, which would just prevent the data being returned to your computer
either of those can easily be reverted by a user, best solution is to lock your computer with a good password
-
Re: Can I Dissable Internet Connection With VB?
I have just come across this InternetHangUp API, would it help? I know this thread is somewhat old but I can't pass the opportunity to refer the API.
-
Re: Can I Dissable Internet Connection With VB?
I have a gut feeling that API is for DialUp,
-
Re: Can I Dissable Internet Connection With VB?
Quote:
Originally Posted by jmsrickland
I have a gut feeling that API is for DialUp,
What was your first clue! :) Just kidding. The OP is using dial-up but that API isn't working for me so I doubt that it will work for him. I called it like this:
Code:
Option Explicit
Private Declare Function InternetAutodialHangup Lib "wininet.dll" (ByValdwReserved_ As Long) As Long
Public Function HangUpModem() As Boolean
If InternetAutodialHangup(0&) = 0 Then HangUpModem = False Else HangUpModem = True
End Function
Private Sub Command1_Click()
HangUpModem
End Sub
-
Re: Can I Dissable Internet Connection With VB?
Post edited - disregard very buggy command - wouldnt work on my daughters laptop.
code deleted
-
Re: Can I Dissable Internet Connection With VB?
Just want the OP to know that I've spent the better part of today trying every damn API listed in this thread and every link to API's. None of which produced any results. I'm totally bummed out and burned out!
One of the shortcomings of MSComm is the fact that it can't gain priority control over a port in use. If it could, this would be soooo easy. :(
-
Re: Can I Dissable Internet Connection With VB?
Quote:
Originally Posted by technorobbo
Sub LanOff()
Dim ws
Set ws = CreateObject("Wscript.Shell")
ws.Run "netsh interface set interface " & Chr(34) & "Local Area Connection" & Chr(34) & " DISABLE " , 0, True
Set ws = Nothing
End Sub
The OP is NOT using a LAN.
-
Re: Can I Dissable Internet Connection With VB?
Oh, this is really the pits! I've been telling everyone in this thread that the OP is using Dial-Up because he said he's using a Modem. Well, I don't really know that, because people also use the term Modem for cable and DSL, even though it's a misnomer.
The worst part is that there is another active thread that the OP does want to access the Modem and I've been getting these two threads all mixed up. Gee, I haven't even begun to imbibe yet! :afrog:
Happy New Year
-
Re: Can I Dissable Internet Connection With VB?
Not sure if anyone's mentioned it yet (I did read through posts...) but you can get yourself a wireless broadband usb device - plug and play.
Of course you would have buy monthly service as well or it could be on per-mb-basis.
-
Re: Can I Dissable Internet Connection With VB?
Quote:
Originally Posted by CDRIVE
Oh, this is really the pits! I've been telling everyone in this thread that the OP is using Dial-Up because he said he's using a Modem. Well, I don't really know that, because people also use the term Modem for cable and DSL, even though it's a misnomer.
The worst part is that there is another active thread that the OP does want to access the Modem and I've been getting these two threads all mixed up. Gee, I haven't even begun to imbibe yet! :afrog:
Happy New Year
he did say
Quote:
I got a modem and a router.
-
Re: Can I Dissable Internet Connection With VB?
Quote:
Originally Posted by CDRIVE
Oh, this is really the pits! I've been telling everyone in this thread that the OP is using Dial-Up because he said he's using a Modem. Well, I don't really know that, because people also use the term Modem for cable and DSL, even though it's a misnomer.
The worst part is that there is another active thread that the OP does want to access the Modem and I've been getting these two threads all mixed up. Gee, I haven't even begun to imbibe yet! :afrog:
Happy New Year
I have browsed kiaraire's threads and this is the only one that is internet related. If you are referring to this thread then sure you are mixed up, unless svg3414 and kiaraire are the same person.
-
Re: Can I Dissable Internet Connection With VB?
Quote:
Originally Posted by westconn1
he did say
Yes he did. :eek: I hope he comes back and clarifies this issue.
-
Re: Can I Dissable Internet Connection With VB?
Quote:
Originally Posted by dee-u
I have browsed kiaraire's threads and this is the only one that is internet related. If you are referring to
this thread then sure you are mixed up, unless svg3414 and kiaraire are the same person.
Yes, I clearly admitted that I was all screwed up,, and yes, that's the thread. Hey, what can I say....? There is also an apology to you in that thread.
-
Re: Can I Dissable Internet Connection With VB?
Sorry Nothing could help me. I even checked the other thread you gave me,
Maby I dont have enought knowledge to do it right. Its not urgant so thank you all anyway.
Quote:
Originally Posted by dee-u
unless svg3414 and kiaraire are the same person.
Nah. I dont like numbers inside a nickname.
-
Re: Can I Dissable Internet Connection With VB?
You know there are 20 posts (including this one) in this thread but you've only made three and only 1 answered any questions. You have to help by answering questions. Do you want to do this or not?
-
Re: Can I Dissable Internet Connection With VB?
Sure I do. Ask a question.
-
Re: Can I Dissable Internet Connection With VB?
Quote:
Originally Posted by kiaraire
Sure I do. Ask a question.
A good start would be to answer the questions in this thread. ;)
-
Re: Can I Dissable Internet Connection With VB?
A cheap Linksys router can limit internet access from a specific PC based on time and day of the week. Is that automation possible in your enviroment?
-
Re: Can I Dissable Internet Connection With VB?
Quote:
Originally Posted by technorobbo
A cheap Linksys router can limit internet access from a specific PC based on time and day of the week. Is that automation possible in your enviroment?
I think this is a good solution!:)
-
Re: Can I Dissable Internet Connection With VB?
Quote:
Originally Posted by technorobbo
A cheap Linksys router can limit internet access from a specific PC based on time and day of the week. Is that automation possible in your enviroment?
Good idea but I don't have it and I don't wanna buy. Even not to waste a coin on a little chewing gum.
-
Re: Can I Dissable Internet Connection With VB?
What about devcon? Simply you can enable/disable the lan device (in case you are using A/DSL).
DevCon: http://support.microsoft.com/?scid=k...311272&x=9&y=6
This is the line i'm using in my app, to enable a wifi device.
Code:
Shell "cmd /c " + Chr(34) + "devcon.exe enable PCI\VEN_168C*"
By replacing the word "enable" to "disable" will disable the device that matching before the asterisk (*).
-
Re: Can I Dissable Internet Connection With VB?
That's a slick tip Jim and simple too!!:thumb:
-
Re: Can I Dissable Internet Connection With VB?
Can't you execute ipconfig /release?
That would work tho,
Code:
Shell "IpConfig /release"
And
Code:
Shell "IpConfig /renew"
To get the connection back.
-
Re: Can I Dissable Internet Connection With VB?
How do I get IPCONFIG to stay up. When I try to run it using a .BAT file or shelling it with VB it pops up real fast, displays a bunch of stuff, and then goes away. How to keep it up?
-
Re: Can I Dissable Internet Connection With VB?
Quote:
Originally Posted by jmsrickland
How do I get IPCONFIG to stay up. When I try to run it using a .BAT file or shelling it with VB it pops up real fast, displays a bunch of stuff, and then goes away. How to keep it up?
You could put the output to a text box.
Code:
Option Explicit
' Add reference to Windows Script Host Object Model.
Private execAssem As IWshRuntimeLibrary.WshExec
Private Sub Command1_Click()
Text1.Text = ""
With New IWshRuntimeLibrary.WshShell
Set execAssem = .Exec("IPCONFIG /all")
End With
Command1.Enabled = False
Do
With execAssem
With .StdOut
If Not .AtEndOfStream Then
Text1.SelStart = Len(Text1.Text)
Text1.SelText = .ReadAll()
End If
End With
If .Status <> WshRunning Then Exit Do
End With
DoEvents
Loop
Command1.Enabled = True
End Sub
-
Re: Can I Dissable Internet Connection With VB?
Just go into the Vista Help&Support and search on parental controls.
It's already built in.
-
Re: Can I Dissable Internet Connection With VB?
Quote:
Originally Posted by jmsrickland
How do I get IPCONFIG to stay up. When I try to run it using a .BAT file or shelling it with VB it pops up real fast, displays a bunch of stuff, and then goes away. How to keep it up?
Why would you want to keep it up anyway?
-
Re: Can I Dissable Internet Connection With VB?
Quote:
Originally Posted by masterkert3
Why would you want to keep it up anyway?
To read it, what else.
-
Re: Can I Dissable Internet Connection With VB?
Quote:
Originally Posted by masterkert3
Can't you execute ipconfig /release?
That would work tho,
Code:
Shell "IpConfig /release"
And
Code:
Shell "IpConfig /renew"
To get the connection back.
Works great for me.
Code:
Private Sub Form_Load()
Dim InternetStatus As String
Open App.Path & "\InternetStatus.txt" For Input As #1
Line Input #1, InternetStatus
Close #1
If InternetStatus = "Disabled" Then
Command1.Caption = "Enable Internet"
Else
Command1.Caption = "Disable Internet"
End If
End Sub
Private Sub Command1_Click()
Open App.Path & "\InternetStatus.txt" For Output As #1
If Command1.Caption = "Disable Internet" Then
Command1.Caption = "Enable Internet"
Shell "IpConfig /release"
Print #1, "Disabled"
Else
Command1.Caption = "Disable Internet"
Shell "IpConfig /renew"
Print #1, "Enabled"
End If
Close #1
End Sub
-
Re: Can I Dissable Internet Connection With VB?
Ipconfig /release doesn't work for me, I have a static IP, guess it only works on DHCP setups.
-
Re: Can I Dissable Internet Connection With VB?
Quote:
Originally Posted by jmsrickland
To read it, what else.
Ipconfig /release or Ipconfig /renew won't print anything.
-
Re: Can I Dissable Internet Connection With VB?
Quote:
Originally Posted by masterkert3
Ipconfig /release or Ipconfig /renew won't print anything.
It does in my case (Static IP). ;)
>ipconfig /release *Local*
Windows IP Configuration
Adapter Local Area Connection is not enabled for Dhcp.
>ipconfig /renew
Windows IP Configuration
The operation failed as no adapter is in the state permissible for this operation.
-
Re: Can I Dissable Internet Connection With VB?
Quote:
Originally Posted by masterkert3
Ipconfig /release or Ipconfig /renew won't print anything.
I wasn't asking because of that particular case; I was just asking how to keep it up so I can read whatever the output is on the black screen. For example: ipconfig.exe /displaydns
-
Re: Can I Dissable Internet Connection With VB?
Quote:
Originally Posted by Edgemeal
Ipconfig /release doesn't work for me, I have a static IP, guess it only works on DHCP setups.
I have a static IP. So why does it work for me?
-
Re: Can I Dissable Internet Connection With VB?
Code:
Shell "cmd /K ipconfig", vbNormalFocus
That'll keep the cmd open.