Page 1 of 2 12 LastLast
Results 1 to 40 of 42

Thread: [RESOLVED] Can I Dissable Internet Connection With VB?

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2008
    Posts
    61

    Resolved [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.

  2. #2
    Hyperactive Member danecook21's Avatar
    Join Date
    Feb 2008
    Location
    NC, USA
    Posts
    501

    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.

  3. #3
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    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.

  4. #4
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    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
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2008
    Posts
    61

    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.

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  7. #7
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    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.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  8. #8
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Can I Dissable Internet Connection With VB?

    I have a gut feeling that API is for DialUp,

  9. #9
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    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
    <--- 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??

  10. #10
    Fanatic Member technorobbo's Avatar
    Join Date
    Dec 2008
    Location
    Chicago
    Posts
    864

    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.
    Have Fun,

    TR
    _____________________________
    Check out my Alpha DogFighter2D Game Demo and Source code. Direct Download:http://home.comcast.net/~technorobbo/Alpha.zip or Read about it in the forum:http://www.vbforums.com/showthread.php?t=551700. Now in 3D!!! http://home.comcast.net/~technorobbo/AlPha3D.zip or read about it in the forum: http://www.vbforums.com/showthread.php?goto=newpost&t=552560 and IChessChat3D internet chess game

  11. #11
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    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.
    <--- 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??

  12. #12
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    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.
    <--- 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??

  13. #13
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    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!
    Happy New Year
    Last edited by CDRIVE; Dec 31st, 2008 at 09:04 PM.
    <--- 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??

  14. #14
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    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.

  15. #15
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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!
    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

  16. #16
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    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!
    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.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  17. #17
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Can I Dissable Internet Connection With VB?

    Quote 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??

  18. #18
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    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.
    <--- 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??

  19. #19

    Thread Starter
    Member
    Join Date
    Jun 2008
    Posts
    61

    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.

  20. #20
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    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??

  21. #21

    Thread Starter
    Member
    Join Date
    Jun 2008
    Posts
    61

    Re: Can I Dissable Internet Connection With VB?

    Sure I do. Ask a question.

  22. #22
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    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.
    <--- 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??

  23. #23
    Fanatic Member technorobbo's Avatar
    Join Date
    Dec 2008
    Location
    Chicago
    Posts
    864

    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?
    Have Fun,

    TR
    _____________________________
    Check out my Alpha DogFighter2D Game Demo and Source code. Direct Download:http://home.comcast.net/~technorobbo/Alpha.zip or Read about it in the forum:http://www.vbforums.com/showthread.php?t=551700. Now in 3D!!! http://home.comcast.net/~technorobbo/AlPha3D.zip or read about it in the forum: http://www.vbforums.com/showthread.php?goto=newpost&t=552560 and IChessChat3D internet chess game

  24. #24
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    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!
    <--- 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??

  25. #25

    Thread Starter
    Member
    Join Date
    Jun 2008
    Posts
    61

    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.

  26. #26
    Frenzied Member Jim Davis's Avatar
    Join Date
    Mar 2001
    Location
    Mars base one Username: Jim Davis Password: yCrm33
    Posts
    1,284

    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 (*).

  27. #27
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Can I Dissable Internet Connection With VB?

    That's a slick tip Jim and simple too!!
    <--- 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??

  28. #28
    Addicted Member
    Join Date
    May 2007
    Location
    Belgium
    Posts
    156

    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.

  29. #29
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    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?

  30. #30
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    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

  31. #31
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    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.

  32. #32
    Addicted Member
    Join Date
    May 2007
    Location
    Belgium
    Posts
    156

    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?

  33. #33
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    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.

  34. #34
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    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

  35. #35
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    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.

  36. #36
    Addicted Member
    Join Date
    May 2007
    Location
    Belgium
    Posts
    156

    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.

  37. #37
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    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.

  38. #38
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    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

  39. #39
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    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?

  40. #40
    Addicted Member
    Join Date
    May 2007
    Location
    Belgium
    Posts
    156

    Re: Can I Dissable Internet Connection With VB?

    Code:
    Shell "cmd /K ipconfig", vbNormalFocus
    That'll keep the cmd open.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width