Click here to Skip to main content
13,899,227 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


17 bookmarked
Posted 23 Nov 2013
Licenced CPOL

Wi-Fi Timer

, 25 Nov 2013
Rate this:
Please Sign up or sign in to vote.
Schedule your wifi status


In many situations, I needed to control wi-fi status on my PC. Tuning on/off automatically [midnight > morning] well, because my ISP doesn't invoice on traffic in that interval, and some programs need/use large amount of data..


This is an easy way is to use command prompt cmd.exe.

netsh.exe does the job. [under administrator privileges]*

Enable Interface: netsh interface set interface "interfaceName" enable

Disable Interface: netsh interface set interface "interfaceName" disable

Using the Code

In brief, running this command in C#. By starting netsh.exe process with the above explained arguments:

private enum Status
private static void SetStatus(string interfaceName, Status status)
    string state = status == Status.Online ? "enable" : "disable";
    string arguments = "interface set interface \"{0}\" {1}";
    string args = string.Format(arguments, interfaceName, state);
    var NetshStartInfo = new System.Diagnostics.ProcessStartInfo("netsh", args)
        CreateNoWindow = true,
        RedirectStandardOutput = true,
        UseShellExecute = false,
        WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden
    var Netsh = new System.Diagnostics.Process
        StartInfo = NetshStartInfo

The source code includes usage of the application settings to load/save options, Linq expressions, and some WPF styling...

* to run with administrator permission, add to the app.manifest file in solution explorer these line of code into:

<asmv1:assembly ...>  
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        <requestedExecutionLevel level="highestAvailable" uiAccess="false" />

Points of Interest

It's a light way. Usage is up to certain limits and conditions. Advanced solution can be by scheduling firewall rules on certain programs. And starting them with arguments, etc.

Thanks! Big Grin | <img src=


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Fady Aro
Technical Lead
Lebanon Lebanon
Electronics, Telecommunications, Development, Music!

You may also be interested in...

Comments and Discussions

BugStay where it was... Pin
Peter Leow22-Apr-14 1:45
professionalPeter Leow22-Apr-14 1:45 
GeneralRe: Stay where it was... Pin
OriginalGriff22-Apr-14 1:59
protectorOriginalGriff22-Apr-14 1:59 
GeneralMy vote of 5 Pin
johannesnestler25-Nov-13 4:35
memberjohannesnestler25-Nov-13 4:35 
GeneralRe: My vote of 5 Pin
Fady Aro25-Nov-13 8:35
professionalFady Aro25-Nov-13 8:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06 | 2.8.190306.1 | Last Updated 25 Nov 2013
Article Copyright 2013 by Fady Aro
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid