Click here to Skip to main content
13,865,831 members
Click here to Skip to main content
Add your own
alternative version


70 bookmarked
Posted 10 Aug 2009
Licenced CPOL

Turn On Your PC/Computer Programmatically / Automatically –Wake On LAN ( WOL ) Over Internet- Wake On WAN ( WOW)

, 10 Aug 2009
Rate this:
Please Sign up or sign in to vote.
Start your Computer by C , C++ , JAVA , .NET ..


Everyone of us turns off the machine many times in a day. We do it by a single mouse click on “Turnoff/Shutdown” button in any OS or using 'Shutdown' command typing in command prompt or Shell. Restarting of PC follows the same procedure. Are there any other ways to boot the machine without pressing 'power on' button in CPU manually when PC is in Shutdown state?
Network administrator can shutdown or restart all machines in a network by a single mouse click. Can he start all machines in LAN by a single mouse click when PCs are in shutdown state?
Yes, it can easily be done if your PC is connected to a network, be it in LAN (Local Area Network) or WAN (Wide Area Network).

So at the end of the day, when you leave office/college by thinking my PC is shutdown, network admin cannot scan your PC. But, administrator sitting at his desktop can boot your machine and perform necessary activities using remote desktop.

Surprised!!!!. I know you are thinking that when the computer is in shutdown state, there is no OS / no program running to do it. So who will do the job for me ????
Hold on!!!!


This article assumes you have minimum networking knowledge and have full access to your PC/Router. Yes, to do it you require minimum support from Hardware / OS / Router. The good thing is that most of the modern hardware and OS support it.


When you turn off your PC, all devices go off state but a small networking device known as NIC (Network Interface Card) remains on (depending on your NIC settings) and waiting for receiving messages from other network devices.

A special message called 'Magic Code' once received by it boots the PC using special power circuit called 'WOL connector' present in mother board.
A special utility program from other running PC creates 'Magic Packet' which contains MAC (Media Access Control) of target machine and broadcasts it in the network. All NIC cards present in the whole network receive the 'Magic packet' but only the NIC having same MAC address which is present in magic packet boots the PC.
This is not a new technology but not used widely for lack of security. However, some NICs support the security feature called 'SecureOn' which allows you to set a "Magic Packet password" of 6 bytes.

My PC is Connected to LAN and is in Shutdown State. I Want to Turn It On From a Different Machine

  • Turn off your PC and observe whether your LAN card's light is blinking or not. If yes, your LAN card supports it. Not blinking ... wait! Don't be disappointed. Turn on your PC. Go to LAN Card setting in control Panel and enable "Allow this device to bring the computer on". You may find a different name of this property in different OSs.

    Here is the screen shot taken from Windows OS for Intel Pro VM LAN Card:

    Shutdown PC again and see if it is blinking now. No? Stop reading here. Your NIC does not support it.

  • Open BIOS setup (Pressing F10 / Other key) while booting your PC. Go to "Power Option" and enable "SME wake up" or "Enable WOL" option or related Option. If no such options are there, stop reading here. Your PC does not support it. We are almost done. Still there are some chances to get a negative result because some mother boards do not have inbuilt "WOL connector" which is required to flow current to the main board.

  • Open your OS. Type " ipconfig /all " in the command prompt or shell. Your MAC address/ Physical address will be displayed. Note it. Now shutdown your PC. Go to a different PC in LAN. Run the attached JAVA program (it requires Java Runtime Environment). Provide Broadcast address ( or check with your network admin) and MAC address. If all things go well, you will find your machine turning on. You need to disable "Bios Password", otherwise you need to enter the password manually. (Scroll below to know a bit more about broadcast address.)

    Below is the MAC address taken from Windows OS: 

Why Are We Using MAC Address? 

When the machine is in shutdown state, there is no IP assigned to PC. - Simple answer.
When we are connected to a network and connect to another PC, we need a unique address to connect.
These are IP address and MAC address. These are unique in a network. When we want to connect to another PC which is in the same LAN, IP address has minimum role. What PC requires to know is the MAC address. But still we connect using IP address in LAN. OK.... It finds out the corresponding MAC address for a given IP from network table called ARP (Address resolution Protocol) table. But in WAN, all connections happen using IP address. OK leave it. It is not within the scope of this article.  

Can I Turn on my PC Over the Internet (From cybercafe / School / College)?  How? 

  • First test whether it is working in LAN. If not, stop reading here. Working? Great!!! Now we have to play with the router. 
  • You need a router. Don't worry. You don't require a corporate router. Modern modem comes with Inbuilt router. Go to router console or router manual. Find out whether it supports "Subnet based Broadcasting". If not, you cannot proceed with router. 
  • Turn your Modem/Router in 'always on' mode. If you don't have static IP, you will get a new IP every time you will switch on your router, not PC. This IP should be globally accessible. Using " ipconfig " command, note your router's IP for the first time.

    The following picture is taken from 'Huawei MT882' data one modem for enabling 'always on' feature:

  • Open any port (Generally 7 or 9) on your router and forward any request coming to this port to your PC. Note: The IP is not exactly your computer's IP which you want to turn on from shutdown state. It is the broadcast address for your IP address. For an example, if your PC's IP is, broadcast address will be If you are unable to calculate your broadcast address, use any 'Online Subnet calculator'.Link: Online Subnet Calculator. This part is the most vital part of settings. Router should broadcast "Magic packet" coming to given port to all PC in LAN (derived by sub net mask). Many routers disable "Subnet based broadcast" by default.You need to enable it. Some routers do not support this feature. (Refer to the Router manual.)

  • Shutdown your PC. Not router. 
  • Go to a different network ( WAN ) and run the attached program. Provide MAC address and Router IP and Port No. which you have just opened in your router. The program will send Magic packet to router at given port. Router is configured to broadcast this 'Magic packet' to all PCs in the LAN (derived by subnet mask in your network) based on subnet, not Machine IP address.  If all things go well, you will find your machine turning on. 
  • If you are behind a restricted firewall, you may not be able to connect to your router. You have to use HTTP tunnelling to achieve this. You can read about HTTP tunnelling from my another article. You may need to run the program more than once since the protocol used here is UDP, not designed for guaranteed packet delivery.

My Router Does Not Support "sub net based broadcast" So?

Use an 'always on machine' in your LAN. Configure your router to forward "Magic Packet" to only 'always on machine'. As soon as 'Always on machine' receives the magic packet from the router, it broadcasts it in LAN and the target machine will wake up since magic packet contains MAC address of your PC which is in shutdown state.


Keeping your NIC card always on takes very little power. So if you want to wake up all your machines by a single mouse click, go ahead. It makes the network administrator's life easy.


  • 11th August, 2009: Initial post


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


About the Author

Software Developer India
India India
SUN certified

You may also be interested in...


Comments and Discussions

Generalscreen shots Pin
Subhajeet Ganguly8-Aug-12 18:52
memberSubhajeet Ganguly8-Aug-12 18:52 
QuestionIt does not work, help!!! Pin
pocho21012-Dec-11 6:28
memberpocho21012-Dec-11 6:28 
Generalhi this is confusing. Pin
jeremy jow30-Jan-10 16:23
memberjeremy jow30-Jan-10 16:23 
Questionany way to do this programatically?? Pin
Cool_Dev30-Nov-09 2:00
memberCool_Dev30-Nov-09 2:00 
AnswerRe: any way to do this programatically?? Pin
Asu-H25-Jan-10 1:13
memberAsu-H25-Jan-10 1:13 
GeneralRe: any way to do this programatically?? Pin
Cool_Dev25-Jan-10 2:13
memberCool_Dev25-Jan-10 2:13 
GeneralGet IP address using MAC address Pin
aecordoba1-Oct-09 2:07
memberaecordoba1-Oct-09 2:07 
GeneralRe: Get IP address using MAC address Pin
Asu-H9-Oct-09 20:46
memberAsu-H9-Oct-09 20:46 
GeneralThen how to Shutdown Pin
issemak17-Aug-09 4:59
professionalissemak17-Aug-09 4:59 
GeneralRe: Then how to Shutdown Pin
Asu-H17-Aug-09 7:11
memberAsu-H17-Aug-09 7:11 
GeneralRe: Then how to Shutdown Pin
issemak18-Aug-09 4:06
professionalissemak18-Aug-09 4:06 
GeneralRe: Then how to Shutdown: Java Pin
issemak18-Aug-09 4:09
professionalissemak18-Aug-09 4:09 
GeneralRe: Then how to Shutdown: Java Pin
Asu-H18-Aug-09 17:17
memberAsu-H18-Aug-09 17:17 

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
Web04 | 2.8.190214.1 | Last Updated 11 Aug 2009
Article Copyright 2009 by Asu-H
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid