Enable Wake-On-LAN via CLI

The following will allow you to enable Wake-On-LAN for your network card interface. I’ve only test this on a Windows 7 system, and it’s been working properly in my environment.

By default, my systems have the following configuration:



After running the script, this is how it should look like:



Here’s the code, just copy the code and save with either a .BAT or .CMD extension.

@ECHO OFF
REM ********************************
REM ***** DESCRIPTION **************
REM ********************************
REM ***** Identify network card and write its name
REM ***** to file C:\Users\Default\AppData\Local\Temp\adapters.txt
REM ***** Name of network card is based on the following
REM ***** keywords: gigabit network connection ethernet
REM ********************************
REM ***** PARAMETERS BREAKDOWN *****
REM ********************************
REM ***** POWERCFG
REM ***** -devicequery Return a list of devices that meet the specified criteria
REM ***** wake_from_any Return all devices that support waking the system from any sleep state.
REM ********************************
REM ***** FINDSTR
REM ***** /I (or /i) Specifies that the search is not to be case-sensitive
REM ********************************
REM ***** Note: this is one long command line (word wrapping may show it as two lines)
POWERCFG -devicequery wake_from_any | FINDSTR /i "gigabit network connection ethernet" > C:\Users\Default\AppData\Local\Temp\adapters.txt

REM ********************************
REM ***** DESCRIPTION **************
REM ********************************
REM ***** Enable WoL on device with the following
rem ***** keywords in its name: gigabit network connection ethernet
REM ********************************
REM ***** PARAMETERS BREAKDOWN *****
REM ********************************
REM ***** POWERCFG
REM ***** -deviceenablewake Enable the device to wake the system from a sleep state
REM ********************************
FOR /F "tokens=*" %%i IN (C:\Users\Default\AppData\Local\Temp\adapters.txt) DO POWERCFG -deviceenablewake "%%i"

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: