CM 2012 Wake on LAN – Right click tools


Hi,

First of all our best wishes for the new year.

Today was my first day back after almost 2 weeks off and I immediately had something interesting at my customer.

They wanted to use the Wake On LAN feature of Configuration Manager 2012, that’s why I have installed the right click tools for the Configuration Manager 2012 Console. More information about the right click tools can be found here: http://bscexp.blogspot.be/2012/05/sccm-2012-right-click-tools.html

Installing the right click tools didn’t work because Configuration Manager 2012 is installed on the D: partition, so I manually copied all folders in the right place

After copying the right click tools new options are available for every computer. The option I’m interested in at the moment is Wake On LAN (marked in yellow on the following screenshot)

 04012013_SCCM2012_1

When this option is clicked a messagebox appears which states that sending the WakeUp to the specific computer succeeded, but if I look at the computer doesn’t wake up at all.

04012013_SCCM2012_2

When using the Wake On LAN feature of Altiris Deployment Server for example the Wake On LAN did succeed. So I started to examine the differences between both. After using some network tracing tools like WireShark I saw that the Wake On LAN functionality provided by the right click tools for Configuration Manager 2012 did a broadcast to 255.255.255.255 and the Wake On LAN from Altiris performed a broadcast to the broadcastaddress of the VLAN where the client was located (eg. 10.16.92.255). After some more digging in I found out that the switches dropped all traffic with destination 255.255.255.255.

So what I needed to do was editing the Wake On LAN functionality of the right click tools to make sure the VLAN broadcast address was targeted, now I will describe how I did that.

First I looked at the console extension XML to see what commandline was started when I clicked Wake On LAN from the Configuration Manager 2012 console. The XML is located in the installation directory of Configuration Manager: D:\Program Files\Microsoft Configuration Manager\AdminConsole\XmlStorage\Extensions\Actions\ed9dee86-eadd-4ac8-82a1-7234a4646e62.

<ActionDescription Class=”Executable” DisplayName=”Wake On LAN” MnemonicDisplayName=”Wake On LAN” Description=”Send Wake on LAN signal to system”>

<ShowOn>

<string>ContextMenu</string>

</ShowOn>

  <Executable>

          <FilePath>wscript.exe</FilePath>

          <Parameters> “C:\Program Files\SCCMConsoleExtensions\SCCMAction.vbs” ##SUB:Name## W ##SUB:ResourceID## ##SUB:__Server## ##SUB:__Namespace##</Parameters>

        </Executable>

      </ActionDescription>

The area marked in boldshows what script is started when Wake On LAN is clicked, so I’ve opened this script.

 Sub WakeOnLAN

    On Error Resume Next

     Set objSMSWMIService = GetObject(“winmgmts:{impersonationLevel=impersonate}!\\” & strSiteServer & “\” & strNameSpace)

    Set colMACAddress = objSMSWMIService.ExecQuery(“SELECT * FROM SMS_G_System_NETWORK_ADAPTER_CONFIGURATION WHERE ResourceID='” & strResourceID & “‘ AND IPAddress IS NOT NULL”)

    For Each instance in colMACAddress

        strMACAddress = instance.MACAddress

        strWOLAddress = (Replace(instance.MACAddress,”:”,””))

         WshShell.Run chr(34) & strCurrentPath & “WOL.exe” & chr(34) & ” ” & strWOLAddress,0

        strWOLSent = strWOLSent & vbCrLf & strMACAddress

    Next

     ResultMsg = MsgBox(“Wakeup sent to the following MACs for ” & strComputer & vbCrLf & strWOLSent,64,strVersion)

    WScript.Quit

End Sub

It is clear that the WOL.exe is started with the parameter strWOLAddress (which is the Macaddress without colons (:)).

WOL.exe doesn’t support entering the VLAN broadcastaddress so I searched for another exe-file that was able to do that. I found an alternative mc-wol.exe which was able to handle the broadcastaddress. More information about mc-wol.exe: http://www.matcode.com/wol.htm

First of all I copied mc-wol.exe to the folder C:\Program Files\SCCMConsoleExtensions where all the rest of the scripts, exe-files,… are located. This will make sure the new exe can be used from the Configuration Manager console.

Next thing to do was getting the subnet from the specific resource from Configuration Manager. That was rather easy because the Wake On LAN sub in SCCMAction.vbs contains the functionality to retrieve information from Configuration Manager. Just adding the intelligence to retrieve the IP address did the trick. Afterwards splitting the IP address and replacing the last part with 255 (eg. IP: 10.16.92.56 –> 10.16.92.255).

Final thing to do is building up the new commandline using mc-wol.exe instead of the default wol.exe.

 

Sub WakeOnLAN

    On Error Resume Next

     Set objSMSWMIService = GetObject(“winmgmts:{impersonationLevel=impersonate}!\\” & strSiteServer & “\” & strNameSpace)

    Set colMACAddress = objSMSWMIService.ExecQuery(“SELECT * FROM SMS_G_System_NETWORK_ADAPTER_CONFIGURATION WHERE ResourceID='” & strResourceID & “‘ AND IPAddress IS NOT NULL”)

    For Each instance in colMACAddress

        strMACAddress = instance.MACAddress

strIPAddress = instance.IPAddress(0)

strIPSplit = split (strIPAddress,”.”)

strIP = strIPSplit(0) & “.” & strIPSplit(1) & “.” & strIPSplit(2) & “.255”

       WshShell.Run chr(34) & strCurrentPath & “mc-wol.exe” & chr(34) & ” ” & strMACAddress & ” /a ” & strIP

        strWOLSent = strWOLSent & vbCrLf & strMACAddress

    Next

     ResultMsg = MsgBox(“Wakeup sent to the following MACs for ” & strComputer & vbCrLf & strWOLSent,64,strVersion)

    WScript.Quit

End Sub

 

Save the new SCCMAction.vbs and try again.

Now the VLAN broadcast address will be targeted and the computer will be able to perform Wake On LAN.

Hope this helps.

Cheers,

B

Advertisements

10 Responses to CM 2012 Wake on LAN – Right click tools

  1. Milos says:

    Thanks for the analyzing the script. I think the wolcmd.exe used now suports broadcast target – I tested wolcmd.exe <> 10.99.24.255 255.255.248.0 will return message that is is sending to bcast address 10.99.39.255. I am now trying to modify it that it is sending just to the ethernet adapter even though SCCM knows it on wireless adapter only …

  2. sso@project-nine.ch says:

    Great Analyse of the problem. If you need to specify another WoL Port, the wolcmd.exe can handle that.

  3. Harm says:

    Hi there, the Now Micro Right Click Tools I use make use of the ‘Device – WOL.ps1’ script which uses the built-in function ‘Wol’ as far as I can see. The wolcmd.exe is declared but never used, and I can’t find it anywhere. So any help on adjusting this script to use the mc-wol.exe ? 😦 :p

  4. Kevin says:

    where does one download mc-wol.exe these days?

  5. Hi there, Matcode site is down now, somebody have the mc-wol.exe file?

  6. George Morgan says:

    Hi,
    I found this article helpful. I need the script changed a bit as I needed to specify the WOL port. I used WolCmd.exe to do this.
    My script is
    WshShell.Run chr(34) & strCurrentPath & “WolCmd.exe” & chr(34) & ” ” & strMACAddress & ” ” & strComputer & ” 255.255.255.0 7″
    255.255.255.0 being the broadcast subnet
    7 being the WOL port

    I need help though as my scripting is limited to make the same change to the “SCCMAction-Col.hta” script to do WOL for Collections.
    The strComputer viable is not used in the “SCCMAction-Col.hta” so I need a way to add that or an equivocate viable.
    Anyone able to give me a help with that?
    Thank you

    George

  7. George Morgan says:

    Hi,
    I found this post helpful. I need the script changed a bit as I needed to specify the WOL port. I used WolCmd.exe to do this.
    My script is
    WshShell.Run chr(34) & strCurrentPath & “WolCmd.exe” & chr(34) & ” ” & strMACAddress & ” ” & strComputer & ” 255.255.255.0 7″
    255.255.255.0 being the broadcast subnet
    7 being the WOL port

    I need help though as my scripting is limited to make the same change to the “SCCMAction-Col.hta” script to do WOL for Collections.
    The strComputer viable is not used in the “SCCMAction-Col.hta” so I need a way to add that or an equivocate viable.
    Anyone able to give me a help with that?
    Thank you

    George

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