|
-
Nov 7th, 2008, 10:26 AM
#1
Thread Starter
Member
[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.
-
Nov 7th, 2008, 10:38 AM
#2
Hyperactive Member
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.
-
Nov 7th, 2008, 07:31 PM
#3
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.
-
Nov 8th, 2008, 05:12 AM
#4
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
-
Nov 9th, 2008, 01:48 PM
#5
Thread Starter
Member
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.
-
Nov 9th, 2008, 03:35 PM
#6
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Dec 31st, 2008, 02:17 PM
#7
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.
-
Dec 31st, 2008, 04:14 PM
#8
Re: Can I Dissable Internet Connection With VB?
I have a gut feeling that API is for DialUp,
-
Dec 31st, 2008, 05:38 PM
#9
Re: Can I Dissable Internet Connection With VB?
 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
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Dec 31st, 2008, 08:13 PM
#10
Fanatic Member
Re: Can I Dissable Internet Connection With VB?
Post edited - disregard very buggy command - wouldnt work on my daughters laptop.
code deleted
Last edited by technorobbo; Dec 31st, 2008 at 08:41 PM.
-
Dec 31st, 2008, 08:38 PM
#11
-
Dec 31st, 2008, 08:41 PM
#12
Re: Can I Dissable Internet Connection With VB?
 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.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Dec 31st, 2008, 08:58 PM
#13
-
Dec 31st, 2008, 09:11 PM
#14
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.
-
Jan 1st, 2009, 04:19 AM
#15
Re: Can I Dissable Internet Connection With VB?
 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!
Happy New Year
he did say
I got a modem and a router.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jan 1st, 2009, 07:52 AM
#16
Re: Can I Dissable Internet Connection With VB?
 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!
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.
-
Jan 1st, 2009, 03:59 PM
#17
Re: Can I Dissable Internet Connection With VB?
 Originally Posted by westconn1
he did say
Yes he did. I hope he comes back and clarifies this issue.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Jan 1st, 2009, 04:10 PM
#18
Re: Can I Dissable Internet Connection With VB?
 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.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Jan 16th, 2009, 03:13 PM
#19
Thread Starter
Member
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.
 Originally Posted by dee-u
unless svg3414 and kiaraire are the same person.
Nah. I dont like numbers inside a nickname.
-
Jan 16th, 2009, 08:54 PM
#20
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?
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Jan 17th, 2009, 05:46 AM
#21
Thread Starter
Member
Re: Can I Dissable Internet Connection With VB?
Sure I do. Ask a question.
-
Jan 17th, 2009, 08:45 AM
#22
Re: Can I Dissable Internet Connection With VB?
 Originally Posted by kiaraire
Sure I do. Ask a question.
A good start would be to answer the questions in this thread.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Jan 17th, 2009, 10:56 AM
#23
Fanatic Member
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?
-
Jan 17th, 2009, 12:17 PM
#24
Re: Can I Dissable Internet Connection With VB?
 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!
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Jan 21st, 2009, 12:41 PM
#25
Thread Starter
Member
Re: Can I Dissable Internet Connection With VB?
 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.
-
Jan 21st, 2009, 12:52 PM
#26
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 (*).
-
Jan 21st, 2009, 04:48 PM
#27
-
Jan 21st, 2009, 04:56 PM
#28
Addicted Member
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.
-
Jan 21st, 2009, 05:23 PM
#29
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?
-
Jan 21st, 2009, 06:03 PM
#30
Re: Can I Dissable Internet Connection With VB?
 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
-
Jan 21st, 2009, 06:08 PM
#31
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.
-
Jan 22nd, 2009, 12:36 PM
#32
Addicted Member
Re: Can I Dissable Internet Connection With VB?
 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?
-
Jan 22nd, 2009, 12:43 PM
#33
Re: Can I Dissable Internet Connection With VB?
 Originally Posted by masterkert3
Why would you want to keep it up anyway?
To read it, what else.
-
Jan 22nd, 2009, 02:38 PM
#34
Re: Can I Dissable Internet Connection With VB?
 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
-
Jan 22nd, 2009, 02:57 PM
#35
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.
-
Jan 22nd, 2009, 03:26 PM
#36
Addicted Member
Re: Can I Dissable Internet Connection With VB?
 Originally Posted by jmsrickland
To read it, what else.
Ipconfig /release or Ipconfig /renew won't print anything.
-
Jan 22nd, 2009, 03:52 PM
#37
Re: Can I Dissable Internet Connection With VB?
 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.
-
Jan 22nd, 2009, 04:08 PM
#38
Re: Can I Dissable Internet Connection With VB?
 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
-
Jan 22nd, 2009, 04:10 PM
#39
Re: Can I Dissable Internet Connection With VB?
 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?
-
Jan 22nd, 2009, 04:27 PM
#40
Addicted Member
Re: Can I Dissable Internet Connection With VB?
Code:
Shell "cmd /K ipconfig", vbNormalFocus
That'll keep the cmd open.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|