topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Monday October 7, 2024, 6:20 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Idea: hotkey to disable/enable nic  (Read 18615 times)

techidave

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,044
    • View Profile
    • Donate to Member
Idea: hotkey to disable/enable nic
« on: February 11, 2009, 07:00 AM »
Been searching for something that will let me disable or enable the nic on either vista or xp.  I could press a couple of keys like ctrl+shift+n and then it would to check the current status of the nic and then perform the appropriate action to turn it off or on.

I know I could just right click the 2 little monitors and choose disable or enable but that isn't what I want.  It would be nice if it could only be run under administrative user.

Most of the programs I have found have been for wireless nics but I need one for a desktop connected via a cable.

electronixtar

  • Member
  • Joined in 2007
  • **
  • Posts: 141
    • View Profile
    • Donate to Member
Re: Idea: hotkey to disable/enable nic
« Reply #1 on: February 11, 2009, 11:50 AM »
if using Vista try
netsh interface set interface <interface name> DISABLED
For example to disable an interface with its default name “Local Area Connection,” run:
netsh interface set interface “Local Area Connection” DISABLED
To enable the interface, you'd then run:
netsh interface set interface “Local Area Connection” ENABLED

techidave

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,044
    • View Profile
    • Donate to Member
Re: Idea: hotkey to disable/enable nic
« Reply #2 on: February 11, 2009, 12:24 PM »
thanks est for a vista solution.  now we can find an xp solution.

40hz

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 11,858
    • View Profile
    • Donate to Member
Re: Idea: hotkey to disable/enable nic
« Reply #3 on: February 11, 2009, 02:49 PM »
If you're using TCP/IP as your only network protocol, a quick & dirty way do it in XP would be to have the NIC drop it's IP address assuming you're using DHCP to get your IP address from your router.

This doesn't disable the NIC per sce. But it does render it unable to access the network, so it effectively kills any chance of connecting to it.



To "disable" use: ipconfig /release [adapter]

example: ipconfig /release "Local Area Connection"

To "enable" use: ipconfig /renew [adapter]

If you only have one NIC the adapter name is optional.

For hotkeying, you could write each command string to a separate batch file (e.g. killNIC.bat and wakeNIC.bat) and invoke them with whatever hotkey mapping utility you'd prefer. There are dozens of free ones available for download. You could also map them to an unused function key if your keyboard comes with keymap utility software.

 :Thmbsup:
« Last Edit: February 11, 2009, 02:55 PM by 40hz »

techidave

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,044
    • View Profile
    • Donate to Member
Re: Idea: hotkey to disable/enable nic
« Reply #4 on: February 11, 2009, 05:42 PM »
the free ones i found seemed to be more for wireless nics.  I didn't check them out further to see if they would work on the others.

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: Idea: hotkey to disable/enable nic
« Reply #5 on: February 11, 2009, 08:07 PM »
actually electronixtar's solution is valid even in WinXP. you can use AHK to bind a hotkey to the "toggle nic" action. more info on using netsh here.

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: Idea: hotkey to disable/enable nic
« Reply #6 on: February 11, 2009, 08:16 PM »
Skrommel has already made a script for this here, give ToggleNic a try.

techidave

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,044
    • View Profile
    • Donate to Member
Re: Idea: hotkey to disable/enable nic
« Reply #7 on: February 11, 2009, 09:27 PM »
thanks Lanux.  I did look at Skrommel's stuff but was earlier in the alphabet.  Like looking for DisableNic or NicDisable.  I just quickly scanned it though.

I will try it out. 

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: Idea: hotkey to disable/enable nic
« Reply #8 on: February 11, 2009, 09:48 PM »
yes, given the amount of scripts in the coding snacks forums, it's common to miss one or two. :)

techidave

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,044
    • View Profile
    • Donate to Member
Re: Idea: hotkey to disable/enable nic
« Reply #9 on: February 12, 2009, 04:27 AM »
Now that I look for ToggleNic again on his page, I didn't see it there.  For no more often than I compile ahk scripts, it's a challenge for me to remember what I need to do.   :(

techidave

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,044
    • View Profile
    • Donate to Member
Re: Idea: hotkey to disable/enable nic
« Reply #10 on: February 12, 2009, 04:46 AM »
now that I am trying to compile the script using ahk in vista I get an error.


Error: error opening destination file.

now what...

techidave

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,044
    • View Profile
    • Donate to Member
Re: Idea: hotkey to disable/enable nic
« Reply #11 on: February 12, 2009, 05:28 AM »
I finally was able to compile it.  Had to recompile it because hotkeys were the same as one of the FARR hotkeys.  now it just says its toggling but never disables it.  I am using Vista Business SP1 and I am administrator on the computer.

I also have changed the network connection name unless its not what I think it is.   :(

techidave

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,044
    • View Profile
    • Donate to Member
Re: Idea: hotkey to disable/enable nic
« Reply #12 on: February 12, 2009, 05:34 AM »
now when i try electronix suggestion aboe i get this error

Microsoft Windows [Version 6.0.6001]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.


C:\Users\Dave>netsh interface set interface "Local Area Connection" DISABLED
Area is not an acceptable value for admin.
The parameter is incorrect.




electronixtar

  • Member
  • Joined in 2007
  • **
  • Posts: 141
    • View Profile
    • Donate to Member
Re: Idea: hotkey to disable/enable nic
« Reply #13 on: February 25, 2009, 04:19 PM »
now when i try electronix suggestion aboe i get this error

Microsoft Windows [Version 6.0.6001]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.


C:\Users\Dave>netsh interface set interface "Local Area Connection" DISABLED
Area is not an acceptable value for admin.
The parameter is incorrect.

Check your local connection name on your own machine dude

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: Idea: hotkey to disable/enable nic
« Reply #14 on: February 25, 2009, 08:08 PM »
also if you're using Skrommel's script, you can add as many different names as you want in the following line.

nic=Lokal tilkobling,Local Area Connection,Conexгo de rede local          ;Names of the network connections, separated by comma