Subscribe to Windows IT Pro
January 09, 2002 12:00 AM

Scripting Solutions with WSH and COM: Give Your PCs a Wake-Up Call

Windows IT Pro
InstantDoc ID #23602
Rating: (3)
Downloads
23602.zip

About 5 years ago, PC motherboard manufacturers implemented a new technology called Wake on LAN (WOL) that lets you remotely wake up PCs by sending a data packet, or magic packet, to them over the network. Products that support Wake on LAN include Computer Associates' (CA's) Unicenter TNG Framework, Hewlett-Packard's HP OpenView and HP Toptools, and IBM's Tivoli TME Network Management System.

Rather than purchase yet another product, however, why not use a script to remotely wake up your PCs? If you use NICs and have PCs that support Wake on LAN, you can take advantage of the SendMagicPacket.vbs and SendMagicPacketWithEvents.vbs scripts. To use these scripts, you need to meet several requirements. In addition, you need to know about the OLE custom control (OCX) that makes these scripts possible and how to customize the scripts.

The Scripts' Requirements
To use SendMagicPacket.vbs and Send-MagicPacketWithEvents.vbs, you must meet three requirements. These requirements involve the PC's hardware and software and the NIC's state.

The PC's hardware must support Wake on LAN. The hardware on the PC you want to wake up must support Wake on LAN, and that support must be enabled. Typically, you enable Wake on LAN support through the BIOS. The Web-exclusive sidebar "Wake on LAN Resources" on the Windows Scripting Solutions Web site (http://www.winscriptingsolutions.com) provides resources that you can use to learn about hardware support and configuration.

The PC's OS must support Wake on LAN. You must configure the target PC's Windows OS to support Wake on LAN, which means that you have to adjust the device permissions. In Windows XP, for example, you click Start, right-click My Computer, and select Properties to open the Control Panel System applet. In the applet, select the Hardware tab and click Device Manager to open the Microsoft Management Console (MMC) Device Manager snap-in. A shortcut is to type

%systemroot%\system32\devmgmt.msc

on the command line. After you open the Device Manager snap-in, right-click the appropriate network adapter, then select Properties. Finally, click the Advanced tab and enable Wake on LAN.

The wake-up method must be configured. Managing power in a NIC involves two states: standby or hibernate (the term depends on the Windows OS) and resume. These states are identical to a PC's sleep and wake states, respectively. Setting a NIC to the standby/hibernate state puts the card into a low-power state or, when a network isn't in use, to an off state. Setting a NIC to the resume state wakes up the card. User intervention or network traffic directed to the NIC from the network can prompt the NIC into the resume state. In the case of network traffic, the Network Device Class Power Management Reference Specification, which Microsoft and AMD created, details three default methods for creating events that can wake up a NIC: detection of a change in the network link state, receipt of a network wake-up frame, and receipt of a magic packet. (Manufacturers can also define and implement custom wake-up methods.) SendMagicPacket.vbs and SendMagicPacketWithEvents.vbs rely on the magic packet method.

When you install a NIC, the three default wake-up methods aren't configured for use. "Wake on LAN Resources" provides resources that you can access to learn how to configure a NIC.

A Welcomed Control
In the past, to create a magic packet, you had to write a script that automated the Winsock mswinsck.dll file. Microsoft licensed this version of Winsock from a third party, so you could install Winsock only as part of Microsoft Visual Studio (VS), for which you need a license. Thus, the DLL wasn't freely available. People who had access to this DLL wrote scripts to create magic packets. Listing 1 shows an example of such a script. If you find a script that looks like the one in Listing 1, however, don't use it. It's no longer a worthwhile solution because Ultrajones Software now offers a free OCX called UltraWOL (ultrawol.ocx). With UltraWOL, everyone—not just VS owners—can take advantage of magic packet technology.

To use UltraWOL, you need to install UltraWOL on the PC that will run the script and send the magic packet. You also need to install the Microsoft Visual Basic (VB) 6.0 runtime files on the same PC. "Wake on LAN Resources" includes links for downloading both UltraWOL and the VB 6.0 runtime files. I recommend that you download the VB 6.0 runtime files that have the most recent service pack. The runtime files in VB 6.0 Service Pack 5 (SP5) are

  • asycfilt.dll—a file that contains filters for graphics, such as .jpg and .gif files
  • comcat.dll—the Microsoft Component Category Manager Library
  • msvbvm60.dll—the VB Virtual Machine (VM), which contains all the intrinsic controls and functions necessary for any VB application to run
  • oleaut32.dll—the core Microsoft OLE Automation file
  • olepro32.dll—a placeholder file for an old property-support DLL
  • stdole2.tlb—a file that contains standard OLE type-library information

Related Content:

ARTICLE TOOLS

Comments
  • Anderson
    4 years ago
    May 07, 2008

    I'm interesting in the rest of the information, specially the scripts or vbs

  • ivanoc
    5 years ago
    Feb 16, 2007

    looking for the rest of the text

  • charlieyang
    6 years ago
    Jul 02, 2006

    I'm OK, Thanks

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.