Windows Vista Forums

How to disable and enable my Local Area Connection using scripts

  1. #1


    M Shafaat Guest

    How to disable and enable my Local Area Connection using scripts

    Hi,
    I wish to disable and enable my Local Area Connection using scripts. Can
    anyone suggest a very simple script or command line using netsh etc for
    doing this?



    My main objective is to prevent virus attacks from the Internet when the
    machine is idle by disconnetcting my PC from the home network.



    Best regards,
    M Shafaat




      My System SpecsSystem Spec

  2. #2


    Mayayana Guest

    Re: How to disable and enable my Local Area Connection using scripts

    | My main objective is to prevent virus attacks from the Internet when the
    | machine is idle by disconnetcting my PC from the home network.
    |

    This doesn't exactly answer your question, but there
    are some other options:

    1) Most firewalls have an option to block all traffic.
    Usually there's a popup menu in the systray. (If you're
    using the Windows firewall then you really should
    replace it. Like most things from Microsoft, it's
    designed to be too confusing to use except in the way
    that MS wants you to use it. And that means allowing
    outbound traffic.)

    2) I run my connection through a UPS, which I have on
    my desk. I just physically pull the plug when I'm not
    going online for a period of time. I used to do the same
    when I used a phone modem. The UPS has sockets
    to route the wire through it, so it's easy to access.
    (Of course that won't help if you're using a wireless
    connection.)
    I like the idea of fully blocking inbound connections,
    but I do it even more for outbound connections. It's
    amazing how sleazy corporate software has become.
    It just can't be trusted not to call home. Even Firefox,
    if allowed, will go to its "first run" page to log your
    IP if you don't block it. A few years ago I was installing
    Norton SW 2003 for a friend and it started calling home,
    so I pulled the plug on the network. After that the install
    worked OK, but it stalled for a couple of minutes while it
    tried in vain to get online. What was really irksome was
    that the installer never said it was trying to get online. It
    was designed to be dishonest.



      My System SpecsSystem Spec

  3. #3


    M Shafaat Guest

    Re: How to disable and enable my Local Area Connection using scripts

    Hi,
    Thank you for your reply and good points of view. But as you say I still
    don't get the answer to my question. So I ask you or others to give your
    advice.



    Regards
    M Shafaat


    "M Shafaat" <poppy2@newsgroup> wrote in message
    news:u1HZ2JN0KHA.2196@newsgroup

    > Hi,
    > I wish to disable and enable my Local Area Connection using scripts. Can
    > anyone suggest a very simple script or command line using netsh etc for
    > doing this?
    >
    >
    >
    > My main objective is to prevent virus attacks from the Internet when the
    > machine is idle by disconnetcting my PC from the home network.
    >
    >
    >
    > Best regards,
    > M Shafaat
    >
    >
    >


      My System SpecsSystem Spec

  4. #4


    The Pinky Guest

    Re: How to disable and enable my Local Area Connection using scripts

    maybe you have success with the DOS Command:
    ipconfig /release
    and
    ipconfig /renew
    if you retrieve your IP Adresse by DHCP this should disconnect you and after
    that reconnect...
    you could execute that Dos Command in a vbs script...

    "M Shafaat" <poppy2@newsgroup> schrieb im Newsbeitrag
    news:u1HZ2JN0KHA.2196@newsgroup

    > Hi,
    > I wish to disable and enable my Local Area Connection using scripts. Can
    > anyone suggest a very simple script or command line using netsh etc for
    > doing this?
    >
    >
    >
    > My main objective is to prevent virus attacks from the Internet when the
    > machine is idle by disconnetcting my PC from the home network.
    >
    >
    >
    > Best regards,
    > M Shafaat
    >
    >
    >


      My System SpecsSystem Spec

  5. #5


    BigDaddyJim Guest

    Re: How to disable and enable my Local Area Connection using scripts

    On Mar 31, 5:23*pm, "The Pinky" <Edi...@newsgroup-websys.de> wrote:

    > maybe you have success with the DOS Command:
    > ipconfig /release
    > and
    > ipconfig /renew
    > if you retrieve your IP Adresse by DHCP this should disconnect you and after
    > that reconnect...
    > you could execute that Dos Command in a vbs script...
    >
    > "M Shafaat" <pop...@newsgroup> schrieb im Newsbeitragnews:u1HZ2JN0KHA.2196@newsgroup
    >
    >
    >

    > > Hi,
    > > I wish to disable and enable my Local Area Connection using scripts. Can
    > > anyone suggest a very simple script or command line using netsh etc for
    > > doing this?
    >

    > > My main objective is to prevent virus attacks from the Internet when the
    > > machine is idle by disconnetcting my PC from the home network.
    >

    > > Best regards,
    > > M Shafaat- Hide quoted text -
    >
    > - Show quoted text -
    You might try a script with the DEVCON command-line exe.

    http://support.microsoft.com/kb/311272

    It'll allow you to enable/disable hardware of a specific ID in a
    script.

    Jim

      My System SpecsSystem Spec

  6. #6


    BNSGuy Guest

    Re: How to disable and enable my Local Area Connection using scripts

    On Mar 31, 9:02*am, "M Shafaat" <pop...@newsgroup> wrote:

    > Hi,
    > I wish to disable and enable my Local Area Connection using scripts. Can
    > anyone suggest a very simple script or command line using netsh etc for
    > doing this?
    >
    > My main objective is to prevent virus attacks from the Internet when the
    > machine is idle by disconnetcting my PC from the home network.
    >
    > Best regards,
    > M Shafaat
    Which is most important? dis- and re-enabling your connection? or
    doing so only when the computer is "idle"? The former is relatively
    simple and can be done using a variety of scripting techniques, or
    even batch files. I imagine the latter would not be terribly
    difficult (to some) either.

    I would think the most straight forward way would be to script an
    event sink that is triggered by the screen saver. (not personally sure
    exactly how to do that, but I've seen event triggered actions
    before). when the screen saver fires, the event sink would trigger
    the function to disable/re-enable the internet connection. A caveat
    would be that this would require the/a screen saver to be used. This
    would also allow the screen saver timeout to 'control' the actions of
    the connection dis-/re-enabler.

    If you are not running/able to run a screen saver, or want to define
    conditions other than what would trigger the screen saver... I'm sure
    it's possible, but currently out of my skill set.

      My System SpecsSystem Spec

  7. #7


    M Shafaat Guest

    Re: How to disable and enable my Local Area Connection using scripts

    Hi again,
    I am really thankfull to all nice people who reply to my question.



    I mostly prefer to write a script that "programmatically" performs exactly
    the same actions that you can do manually as follows:
    From the "Network Connections" window, choose a specific connection e.g.
    "Local Area Connection 1", choose the menue "Disable this network device".



    Another script shall do the reverse, i.e. perform the menue "Enable this
    network device" on "Local Area Connection 1".



    I am sure that this is possible but I don't know how to do it. It seems
    likely to me that this is done easily by a command within "netsh".



    Best regards
    M Shafaat


    "BNSGuy" <daniel.a.murray@newsgroup> wrote in message
    news:c6cbd581-57ff-428f-87f8-16c7cf7ec006@newsgroup
    On Mar 31, 9:02 am, "M Shafaat" <pop...@newsgroup> wrote:

    > Hi,
    > I wish to disable and enable my Local Area Connection using scripts. Can
    > anyone suggest a very simple script or command line using netsh etc for
    > doing this?
    >
    > My main objective is to prevent virus attacks from the Internet when the
    > machine is idle by disconnetcting my PC from the home network.
    >
    > Best regards,
    > M Shafaat
    Which is most important? dis- and re-enabling your connection? or
    doing so only when the computer is "idle"? The former is relatively
    simple and can be done using a variety of scripting techniques, or
    even batch files. I imagine the latter would not be terribly
    difficult (to some) either.

    I would think the most straight forward way would be to script an
    event sink that is triggered by the screen saver. (not personally sure
    exactly how to do that, but I've seen event triggered actions
    before). when the screen saver fires, the event sink would trigger
    the function to disable/re-enable the internet connection. A caveat
    would be that this would require the/a screen saver to be used. This
    would also allow the screen saver timeout to 'control' the actions of
    the connection dis-/re-enabler.

    If you are not running/able to run a screen saver, or want to define
    conditions other than what would trigger the screen saver... I'm sure
    it's possible, but currently out of my skill set.



      My System SpecsSystem Spec

  8. #8


    Pegasus [MVP] Guest

    Re: How to disable and enable my Local Area Connection using scripts



    "M Shafaat" <poppy2@newsgroup> wrote in message
    news:eXUyiam0KHA.840@newsgroup

    > Hi again,
    > I am really thankfull to all nice people who reply to my question.
    >
    >
    >
    > I mostly prefer to write a script that "programmatically" performs exactly
    > the same actions that you can do manually as follows:
    > From the "Network Connections" window, choose a specific connection e.g.
    > "Local Area Connection 1", choose the menue "Disable this network device".
    >
    >
    >
    > Another script shall do the reverse, i.e. perform the menue "Enable this
    > network device" on "Local Area Connection 1".
    >
    >
    >
    > I am sure that this is possible but I don't know how to do it. It seems
    > likely to me that this is done easily by a command within "netsh".
    >
    >
    >
    > Best regards
    > M Shafaat
    >
    Since you haven't received many scripting solutions, here is a batch file
    solution. With a small amount of effort you could translate it to a more
    robust VB Script although you would still need to shell out to the Console
    in order to execute devcon.exe. Note that different versions of devcon.exe
    are required for Intel or AMD CPUs.

    Device.bat
    =======
    @echo off
    goto Start
    ---------------------------------------------------
    Enable or disable a device.

    Prerequisite: devcon.exe
    (http://download.microsoft.com/downlo...240/devcon.exe)
    16.4.2006 FNL
    ---------------------------------------------------
    :Start
    SetLocal EnableDelayedExpansion
    set Adapter=Atheros AR5B93 Wireless Network Adapter

    echo.
    if /i "%1"=="enable" goto go
    if /i "%1"=="disable" goto go
    echo Syntax: Device enable / disable
    goto :eof

    :go
    set HWID=x
    set count=0
    set found=no

    devcon hwids "PCI\*" > "%temp%\device.txt"
    for /F "tokens=*" %%* in ('type "%temp%\device.txt"') do (
    set /a count=!count! + 1
    if /i "%%*"=="Name: %Adapter%" set found=yes& set count=1
    if !found!==yes if !count!==3 set HWID=%%*
    )
    if %found%==yes (
    echo HWID=!HWID!
    devcon %1 "!HWID!"
    ) else (
    echo Device "%Adapter%" not found.
    )
    endlocal
    del "%temp%\device.txt"


      My System SpecsSystem Spec

  9. #9


    The Pinky Guest

    Re: How to disable and enable my Local Area Connection using scripts

    Thx, cool tool...
    i am sure with that its possible to realise interesting scripts

    in the case here i am sure it should be possible to read out from WMI
    the networkcards and mix the Info with registry
    HKLM\System\currentControlSet\enum\PCI
    and get so the Hardware ID you want to disable with the Devcon Tool

    nice nice


    "BigDaddyJim" <hungerfordj@newsgroup> schrieb im Newsbeitrag
    news:95a10dc8-7fa3-4712-a834-45d23c7f87f8@newsgroup
    On Mar 31, 5:23 pm, "The Pinky" <Edi...@newsgroup-websys.de> wrote:

    > maybe you have success with the DOS Command:
    > ipconfig /release
    > and
    > ipconfig /renew
    > if you retrieve your IP Adresse by DHCP this should disconnect you and
    > after
    > that reconnect...
    > you could execute that Dos Command in a vbs script...
    >
    > "M Shafaat" <pop...@newsgroup> schrieb im
    > Newsbeitragnews:u1HZ2JN0KHA.2196@newsgroup
    >
    >
    >

    > > Hi,
    > > I wish to disable and enable my Local Area Connection using scripts. Can
    > > anyone suggest a very simple script or command line using netsh etc for
    > > doing this?
    >

    > > My main objective is to prevent virus attacks from the Internet when the
    > > machine is idle by disconnetcting my PC from the home network.
    >

    > > Best regards,
    > > M Shafaat- Hide quoted text -
    >
    > - Show quoted text -
    You might try a script with the DEVCON command-line exe.

    http://support.microsoft.com/kb/311272

    It'll allow you to enable/disable hardware of a specific ID in a
    script.

    Jim



      My System SpecsSystem Spec

  10. #10


    M Shafaat Guest

    Re: How to disable and enable my Local Area Connection using scripts

    Hi again,
    The solution from Pegasus seems interesting to test, I would try it, thank a
    lot to all.



    Regards
    M Shafaat




      My System SpecsSystem Spec

Page 1 of 2 12 LastLast

How to disable and enable my Local Area Connection using scripts
Similar Threads
Thread Forum
Local Area Connection 2 Network & Sharing
local area connection Network & Sharing
Notification Area Balloon Tips - Enable or Disable Tutorials
Local Area Connection > Local Only Vista networking & sharing
Enable or Disable Optimal Performance in Local Area Connection Pro Vista networking & sharing