Solved

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

Posted on 2013-01-21
12
1,622 Views
Last Modified: 2013-01-23
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
Comment
Question by:dmjung
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 16

Expert Comment

by:choward16980
ID: 38802962
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
 

Author Comment

by:dmjung
ID: 38803023
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
 
LVL 53

Assisted Solution

by:McKnife
McKnife earned 250 total points
ID: 38803567
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
 
LVL 43

Accepted Solution

by:
Steve Knight earned 250 total points
ID: 38803605
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
 
LVL 43

Expert Comment

by:Steve Knight
ID: 38803608
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
 

Author Comment

by:dmjung
ID: 38810884
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:dmjung
ID: 38811027
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
 
LVL 53

Expert Comment

by:McKnife
ID: 38811117
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
 
LVL 43

Expert Comment

by:Steve Knight
ID: 38811272
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
 
LVL 43

Expert Comment

by:Steve Knight
ID: 38811284
If that does it, make a shortcut to the batch file, right click, properties, advanced and tick "run as administrator"
0
 

Author Comment

by:dmjung
ID: 38812013
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
 
LVL 43

Expert Comment

by:Steve Knight
ID: 38812502
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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This is the first one of a series of articles I’ll be writing to address technical issues that are always referred to as network problems. The network boundaries have changed, therefore having an understanding of how each piece in the network  puzzl…
Trying to figure out group policy inheritance and which settings apply where can be a chore.  Here's a very simple summary I've written which might help.  Keep in mind, this is just a high-level conceptual overview where I try to avoid getting bogge…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now