Thursday, August 18, 2011

Windows 7: Disable wireless when you connect to Wired network & Vice Versa

If you are willing to spend few minutes for this solution, continue reading. It involves firing a batch file based on event log entries using Task Scheduler.

1. Create a batch file named “Wireless_Disable.bat” with the following contents. Open Notepad, copy/paste the following text and save it as above file name.

netsh interface set interface "Wireless Network Connection" Disable

2. Create another batch file named “Wireless_Enable.bat”. Open Notepad, copy/paste the following text and save it as the above filename.

netsh interface set interface "Wireless Network Connection" Enable

3. Open Event Viewer. Click Start Orb/button and type Event Viewer and select the “Event Viewer” application from search results.

4. Expand Windows Logs and select System.

image

5. I would suggest unplug your network cable from your laptop and plug back in. Click on Filter current log option in Actions pane. In Event ID text box (in the middle), type 9,4 to filter by event id 9 & event id 4. Click OK.

image

6. Find Event Id 9 from the filtered list and double click to open it. Make sure this event is for your correct wired network card. Note down the Source value. In my case it is b57nd60a. Click Close button to close the event properties window.

image

7. Leave the Event Viewer window as it is. Click Start orb/button again and type Task Scheduler. Select Task Scheduler application from search results.

image

8. Click Task Scheduler Library on your left pane. Click on Create Basic Task.. on the Actions pane to create a new scheduled job.

9. On Create a Basic Task section, Type a name (Dock the Laptop) in Name field and type some description about this task. Click Next.

image

9. On Trigger section select When a specific event is logged options and click Next.

image

10. On When an Event is Logged section Select Log as System, Select Source same as you noted down in step 6, and type event ID as 9.Click Next.

image

11. On Action section Select the option Select a program and click Next.

image

12. On Start a Program section click on Browse… button and select the batch file you created in step 1. Click Next.

image

13. Select the check box for Open the Properties dialog for this task.. Click Finish button on Finish section.

image

14. On the task properties dialog box, select the check box for Run with highest privileges and click OK to close.

image

15. Create another basic task by do the steps 7 through 14 again. On Step 9 type task name as "Undock the laptop”. On step 10, type event id as 4 instead of 9.

16. THAT’S IT. Task will automatically fired when you plug and unplug the network cable on your laptop (or dock and undock it).

Try unplugging the network cable from wired network card and watch your wireless network card is enable and vice versa.

Warning: When you change your password for your domain user account you need to update the new password on these two scheduled tasks.

No comments: