• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2198
  • Last Modified:

Help creating a Batch file to disable/enable wireless card in Windows 7

I have a client who needs a SUPER simple solution to handle restarting his wireless.
I would like to create a batch file on his desktop that will disable and restart his wireless card so that when he gets home from work he doesn't have to reboot his laptop (I know...as if that wasn't simple enough).

Anyway, I have never created a batch file before, and so I need some more specific help. I have been trying some tests using Notepad, and I hear about Dev Con.

Can anyone give me some more specifics for what I am looking for? Is this even possible?

Thanks!

This is for a Windows 7 machine.

Luke
0
dmjung
Asked:
dmjung
  • 5
  • 4
  • 2
  • +1
2 Solutions
 
Chris HInfrastructure ManagerCommented:
Open a command prompt on the machine and run the command 'ipconfig /all' without quotes.

Paste the results here.  (I need the adapter name/identifier in order to correctly disable/enable)
0
 
dmjungAuthor Commented:
This is off my laptop, I'll test it here, then adapt it for the client


Windows IP Configuration

   Host Name . . . . . . . . . . . . : DH5VDRP1
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No

Wireless LAN adapter Wireless Network Connection 2:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft Virtual WiFi Miniport Adapter
   Physical Address. . . . . . . . . : 88-9F-FA-6E-B9-7F
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes

Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Realtek PCIe GBE Family Controller
   Physical Address. . . . . . . . . : 78-2B-CB-D0-C0-76
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   IPv4 Address. . . . . . . . . . . : 10.0.0.22(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : Monday, January 21, 2013 7:55:05 AM
   Lease Expires . . . . . . . . . . : Tuesday, January 22, 2013 7:55:05 AM
   Default Gateway . . . . . . . . . : 10.0.0.254
   DHCP Server . . . . . . . . . . . : 10.0.0.254
   DNS Servers . . . . . . . . . . . : 66.90.130.101
                                       66.90.130.10
   NetBIOS over Tcpip. . . . . . . . : Enabled

Wireless LAN adapter Wireless Network Connection:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : DW1520 Wireless-N Half-Mini Card
   Physical Address. . . . . . . . . : 88-9F-FA-6E-B9-7F
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::a536:7d6:575a:4947%10(Preferred)
   IPv4 Address. . . . . . . . . . . : 10.0.0.43(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : Monday, January 21, 2013 7:55:09 AM
   Lease Expires . . . . . . . . . . : Tuesday, January 22, 2013 7:55:09 AM
   Default Gateway . . . . . . . . . : 10.0.0.254
   DHCP Server . . . . . . . . . . . : 10.0.0.254
   DHCPv6 IAID . . . . . . . . . . . : 193503226
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-15-1C-44-CA-78-2B-CB-D0-C0-76
   DNS Servers . . . . . . . . . . . : 66.90.130.101
                                       66.90.130.10
   NetBIOS over Tcpip. . . . . . . . : Enabled

Ethernet adapter VMware Network Adapter VMnet1:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : VMware Virtual Ethernet Adapter for VMnet1
   Physical Address. . . . . . . . . : 00-50-56-C0-00-01
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::d01d:3591:79c2:9780%16(Preferred)
   IPv4 Address. . . . . . . . . . . : 192.168.139.1(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :
   DHCPv6 IAID . . . . . . . . . . . : 520114262
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-15-1C-44-CA-78-2B-CB-D0-C0-76
   DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                       fec0:0:0:ffff::2%1
                                       fec0:0:0:ffff::3%1
   NetBIOS over Tcpip. . . . . . . . : Enabled

Ethernet adapter VMware Network Adapter VMnet8:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : VMware Virtual Ethernet Adapter for VMnet8
   Physical Address. . . . . . . . . : 00-50-56-C0-00-08
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::c17b:4ae7:be48:3da3%17(Preferred)
   IPv4 Address. . . . . . . . . . . : 192.168.142.1(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :
   DHCPv6 IAID . . . . . . . . . . . : 553668694
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-15-1C-44-CA-78-2B-CB-D0-C0-76
   DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                       fec0:0:0:ffff::2%1
                                       fec0:0:0:ffff::3%1
   NetBIOS over Tcpip. . . . . . . . : Enabled

Tunnel adapter isatap.{25AD19DB-62EC-4C78-8FDF-7CB98075594F}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft ISATAP Adapter
   Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes

Tunnel adapter 6TO4 Adapter:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft 6to4 Adapter
   Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes

Tunnel adapter isatap.{757F002B-66A5-455B-8F6A-8D6FFD67CF8F}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft ISATAP Adapter #2
   Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes

Tunnel adapter Teredo Tunneling Pseudo-Interface:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Teredo Tunneling Pseudo-Interface
   Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes

Tunnel adapter isatap.{1DF52A40-0E48-4267-A4FB-3F70D69C49E6}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft ISATAP Adapter #3
   Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes

Tunnel adapter isatap.{1073924D-9A67-4E06-ABEC-A5303D32B3D1}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft ISATAP Adapter #4
   Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes

Tunnel adapter isatap.{626D8353-FF5C-45AC-AA36-99EEDDE613C7}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft ISATAP Adapter #5
   Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes
0
 
McKnifeCommented:
Yes, devcon can be used here but it would be easier to create a shortcut to his WLAN NIC that he can rightclick and select disable and then enable. So open ncpa.cpl and create a shortcut to the NIC on the desktop.

By the way: why would he have to do this in the first place? His connection should adjust automatically.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Steve KnightIT ConsultancyCommented:
Is he hibernating / shutting lid when connected to corporate wireless then and taking a while to sort itself out when it returns?  Try something like this.  Get the name with

wmic nic get name

then use that in

wmic path win32_networkadapter where name="Local Area Connection" call disable
wmic path win32_networkadapter where name="Local Area Connection" call enable

or use the name shown in the network control panel:

netsh interface set interface name="Local Area Connection" disable
netsh interface set interface name="Local Area Connection" enable

Both will have to be run as admin.

Steve
0
 
Steve KnightIT ConsultancyCommented:
And agreed ... would put a shortcut on his desktop to the adapter... or show him the hardware on/off button or Fn key cmbination to turn it on and off, or even just tick the box to always show it in the notification area.
0
 
dmjungAuthor Commented:
Thanks for the input gentlemen.

You're right, he is closing the lid without shutting down and taking it home at night.

I will try these options and see what he prefers...in the end it is about what HE is comfortable with...
0
 
dmjungAuthor Commented:
Steve,

when I use:
wmic path win32_networkadapter where name="Local Area Connection" call disable
wmic path win32_networkadapter where name="Local Area Connection" call enable

and I substitute DW1520 Wireless-N Half-Mini Card in the quotes I get this message back:

Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
                      ReturnValue = 5;
};

What does this mean?
And even though it says successful, it is not disabling the wireless (I put a pause after each line so I could check it)
0
 
McKnifeCommented:
Try these, please: http://answers.microsoft.com/en-us/windows/forum/windows_7-hardware/enabledisable-network-interface-via-command-line/17a21634-c5dd-4038-bc0a-d739209f5081
netsh interface set interface name="Local Area Connection" admin=disabled
works at once if you start it elevated.
The other example
wmic path win32_networkadapter where name="lalala" call disable
worked for me, too.
0
 
Steve KnightIT ConsultancyCommented:
You need to right click, run as administrator on the batch file to make it work.  Thats why I wondered if just giving shortcut to the network card would be as easy for them, as that can be right click enable, right click, disable.

Steve
0
 
Steve KnightIT ConsultancyCommented:
If that does it, make a shortcut to the batch file, right click, properties, advanced and tick "run as administrator"
0
 
dmjungAuthor Commented:
Alright!
You guys all had great ideas, that work. I will be accepting them all as solutions. Depending on what my client wants, will determine which I use on his machine...but you have been VERY helpful!
0
 
Steve KnightIT ConsultancyCommented:
No problem, lots of workarounds, but sometimes easier just to show how to do it "properly"...

Another way is you just set up his home broadband to use the same SSID and authentication method used in the office if it is a simple one.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now