PowerBug PC Power State Manager
Companion Program for TempElert (C) 2003 ItWorks

Click a menu topic to go there:

Back to TempElert Help

1.0 Introduction

PowerBug is a unique and compact program that allows you to control the power state of your PC or a remote PC or server. It is a companion program for TempElert that can be run from the TempElert "run a program on alarm" option so that you can shutdown mission critical computers that may be damaged by high temperature conditions.

For more information on the TempElert Ethernet Thermometer system see www.tempelert.com

PowerBug can run as an application, or as a service, ensuring it can be started automatically on mission critical servers. For workstations with the ability to run as a service, it can be placed in the "Startup" folder to be executed on PC startup.

It can perform these main functions either locally or remotely:

All actions can be done locally or on a remote PC (if the remote PC is running the PowerBug program).

These actions can be performed immediately or scheduled, by using a built-in scheduler.

All actions and options can also be controlled by command line options. This way, you can easily integrate PowerBug in your TempElert "Run Program on Alarm" conditions. You can also create and run a BATCH file of PowerBug commands using its command line execution mode. For example, create a BATCH file that pop up notifies all users on a portion of your network that a shutdown will occur due to an over temperature condition, and then perform the shutdowns 1 minute later.

PowerBug is very small (170 kilobytes) and is very light on resource usage, it can be left running on PC Workstations and Servers with minimal impact on the CPU and Memory usage of these machines.


1.1 System requirements

Back to the Topic Menu


2.0 Installation

Installation on a local or remote machine  is very easy, just copy the PowerBug.exe file somewhere where you can find it ( such as a folder named C:\PowerBug) and double-click the executable.

To uninstall, simply delete the PowerBug.exe file. PowerBug stores its settings in the registry, so you should remove them also, either by selecting ‘Remove settings’ from the file menu or by manually removing them from the registry using ‘regedit.exe’ 
(WARNING: using regedit can damage your windows configuration, so be careful what you do!). The key that you can safely delete is 


If PowerBug starts up, then it first looks for settings in HKEY_CURRENT_USER. If it cannot find any, then it looks in HKEY_LOCAL_MACHINE. This way you can define global settings and per user settings. You will have to create the global settings manually.

To delete the PowerBug service, choose ‘Remove service’ from the service menu. The settings are automatically removed. To manually remove the service settings, delete the registry key


Other registry keys that may be lying around then the service is removed are:

HKEY_LOCAL_MACHINE \System\ControlSet00x\Services\PowerBug 
HKEY_LOCAL_MACHINE \System\ControlSet00x\Enum\Root\LEGACY_PowerBug

These should disappear when your computer is rebooted. They can be safely deleted when the service is removed.

Back to the Topic Menu

3.0 PowerBug Program Usage

3.1 Starting

When you double-click the PowerBug executable, the main window is shown. Here you can select which action to perform and select the appropriate options. To execute the desired action, simply hit the ‘Do it’ button.

Figure 1

Back to the Topic Menu


3.2 Actions

PowerBug supports the following actions:

3.2.1 Logoff

Logs off the current logged on user.

3.2.2 Reboot

Reboots the computer.

3.2.3 Shutdown

Shutdown the computer. 
In NT/2000/XP this will display the standard message ‘It is safe to shutdown you computer’. 
In Win9x/Me this will PowerBug your PC if your hardware supports it

3.2.4 PowerBug

This action will physically power off your computer. Your hardware must support this, for example an ATX motherboard and power supply should support it, but an old AT motherboard probably doesn’t support it. You also have to have ACPI or APM enabled in your bios. And the power options must be correctly configured in the windows control panel. If Windows performs a PowerBug when you do a normal windows shutdown from the start menu, then it will also work with this program.

To enable PowerBug in Windows NT, you will need a hal.dll that is capable of shutting down your workstation. You can try one that's supplied with service pack 4 (or higher): hal.dll.softex
Just extract the service pack (with the /x option),

There are several machine-specific HAL.DLL’s, and you MUST extract the matching HAL*.DLL.SOFTEX from the service pack. To avoid problems when someone overwrites the good HAL.DLL with a bad one it's better to rename HAL*.DLL.SOFTEX to %SystemRoot%\System32\HALPOWER.DLL for instance, copy the line in %SystemDrive%\BOOT.INI which loads the current system, alter the description and append " /HAL=HALPOWER.DLL". Now one can choose between the two HALs and has a fallback if the new one fails.

If you like NT to automatically PowerBug at shutdown, set the following registry key to 1: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\PowerdownAfterShutdown

3.2.5 Standby

If your PC supports it, then this will put your PC into standby mode (sleep mode). If you get a strange error message, then probably on of your device drivers doesn’t support standby. Standby is not supported on NT.

3.2.6 Hibernate

If your PC supports it, then this will put your PC into hibernate mode. If you get a strange error message, then probably on of your device drivers doesn’t support hibernate. You also have to have hibernation enabled in your power settings of the windows control panel (windows 2000 or above). Hibernate is not supported on Windows 95 or NT.

3.2.7 Lock

This action will lock your workstation. This is only supported on Windows 2000 or above.

3.2.8 Wake-On-LAN

This action allows you to start up a remote PC. This remote PC must support Wake-On-LAN. This means that you have to have a network card that is connected via an extra wire to the motherboard (or power supply) to provide some power. In the system BIOS, Wake-On-LAN must also be enabled.

How it works:
The network card constantly monitors the network for a ‘Magic Packet’ when the computer is switched off. This magic packet is a series of bytes that is sent over the network. A magic packet consists of a header (6*0xFF) and the MAC address of the network adapter repeated several times (16 times), for example if your MAC address is 01:02:03:04:05:06 (6 bytes), then the magic packet looks like this:

The network adapter recognizes the sequence and triggers the power supply to turn on the computer.

Back to the Topic Menu

3.3 Where to do the actions

3.3.1 Local Computer

When this radio button is selected, then the action is performed on the local computer. This radio button is unavailable when the action is Wake-On-LAN. This is because there’s no way that you can turn on your own computer...

3.3.2 Remote Computer

When this radio button is selected, then the action is performed on a remote computer. You have to click the ‘Specify’ button to specify on which remote computer to perform the action.

When the action is anything else than Wake-On-LAN, you are presented with the following dialog box:

Figure 2

Figure 3

You have to specify whether you want to use the credentials of the user that you used to log into windows. In that case, you don’t have to supply a username and password.

If your current account is not allowed to shutdown the remote machine, then you can specify another username and password to connect to the remote machine that has the rights to shutdown the machine. This username can be a username of your current domain, then you only need to specify the username and password. If the user is from a different domain or the remote computer’s local domain, then you have to prefix the username with the domain name (e.g.: DOMAIN\Username), see figure 3.
Note that if you currently have a drive mapping of printer mapping to the remote machine, you cannot specify another username, this is an NT restriction.

This mode is only supported from and to NT/2000 computers. No Windows 9x/Me support!

When you do not select the 'use NT protocol' checkbox, then PowerBug must be running on the remote machine, either as a service or interactive with the ‘Allow remote’ option enabled.
When that is the case, then all actions are possible on the remote machine and it doesn’t matter which version of windows is running there. Of course, you can still only perform actions that the remote OS supports…

When the action is ‘Wake-On-LAN’, then you are presented with the following dialog box:

Figure 4

You have to specify the remote computer’s IP address, subnet mask and MAC address. The IP address and subnet mask are necessary to calculate the broadcast address. The magic packet is only broadcasted to the right subnet. The MAC address is the physical hardware address of the computer’s network adapter. You can click the ‘Lookup’ button to fin the hardware address. This performs a ping to the remote computer and then looks into the ARP table for the IP address. This means that the lookup may not always work correctly. If the lookup fails, then you must get the MAC address from the remote computer itself by inspecting the network adapter’s properties. The MAC address is a series of 12 hexadecimal 
numbers. Some adapters may display the MAC address as XX-XX-XX-XX-XX-XX, but in PowerBug it must be specified without the dashes.

Back to the Topic Menu

3.4 When to do the actions

3.4.1 Immediate

Executes the desired action immediately when you press the ‘Do it’ button.

3.4.2 Scheduled

Executes the action at a certain moment in time. Click the ‘Schedule’ button to specify when to execute the action.

Figure 5

In the time field, you can specify the time when the action must be performed. The time format is hh:mm (0-23 hours).

The date radio box lets you choose the days on which the action must be performed:

3.4.3 After a process stops

Executes the action when some running process finishes. Click the ‘Process’ button to specify the process.

Figure 6

Here you can type the exact process name of choose the name from the current process list by clicking the ‘…’ button.

Figure 7

PowerBug will poll the running processes every second. When the specified process is not running, the action will be executed. This can be useful for shutting down your PC when a certain program has finished or even as a watchdog to reboot the PC when a program that should be running has died.

Back to the Topic Menu

3.5 Options

3.5.1 Warning Message

With this option you can give a warning message to the user before performing the 
action. Click the ‘Message’ button to specify the message properties:

Figure 8

You can enter the number of seconds that the warning message must be shown. When the seconds have passed, then the action is performed.

You can also specify the message text that must be shown.

If you want a sound to be played when the dialog box is shown, then you can select the ‘Play a sound’ checkbox. Then you must also specify the sound file that must be played. If the action must be performed on a remote computer, then the sound file must also exist on the remote computer!

3.5.2 Run a program

This option allows you to run a program before the action is executed. This can be useful to properly shutdown some other program before shutting down your PC. Click the ‘Program’ button to enter the program options:

Figure 9

You must enter the program that must be executed, or choose it from a list by clicking the ‘…’ button. You can also specify the startup directory for the program of select it from a list by clicking the ‘…’ button.

If you need to run multiple programs, then you should put them inside a batch file and then call the batch file from within PowerBug.

3.5.3 Force applications to close

This option is useful for forcing running applications to close. Otherwise some applications may not exit when windows is shut down because they popup a dialog box or because they ’hang’. This option kills all running programs before logging off, rebooting, shutdown or PowerBug.
This also implies that any changes made in running programs will not be saved, so for example if you have a text editor open with unsaved changes, then the editor will be closed without asking you to save the changes!

3.5.4 Visible in tray

When this option is selected, then the PowerBug icon will be visible in the system tray when the ‘Do it’ button has been pressed and a non-immediate action has been selected. Otherwise, PowerBug will seem to have disappeared and there’s no way to make it reappear.

3.5.5 Allow cancel

When this option is selected, then you will be able to cancel any chosen action (except when ‘Immediate’ execution is selected). You will be able to cancel the action from the system tray and in the warning dialog (if those options are set).

3.5.6 Allow remote control

When this option is selected, then other computers can connect to your PC and do all actions that PowerBug supports on your PC remotely. This is useful when running PowerBug as a service and when you’re the network administrator, then you can reboot remote machines from your PC. Click the ‘Settings’ button to specify remote control options:

Figure 10

You can specify the TCP port number where PowerBug listens to for connections. You can also specify a password that remote computers must enter before they gain access to your PC. This password is encrypted and stored in the registry.

Back to the Topic Menu

3.6 Program Menu

3.6.1 File menu

Figure 11

3.6.2 Service

Figure 12

Back to the Topic Menu

3.7 Event Logging

If you have Windows NT/2000/XP, then you can always check the event log (application log) for messages from PowerBug. Here you can find information and error messages about the actions that were performed.

Back to the Topic Menu

4.0 Command-line options

You can control every option and setting from the command-line. This makes PowerBug excellent for use in batch files. Some options have changed since previous releases, so check your batch files! If you do PowerBug /?, you will get an overview of all the options (look above for a description of all the settings):

Usage: PowerBug action [options]

Actions: logoff, reboot, shutdown, PowerBug, standby, hibernate, lock or WOL


-warn 		: Show a warning message before doing the action
-warntime s 	: Show the warning message for s seconds
-playsound 	: Play a sound when the warning is displayed
-soundfile “f” 	: Specifies the .WAV file that must be played
-msg "m" 		: Specifies the warning message, use \n for a newline character
-force 		: Force applications to close
-wait s 		: Wait s seconds before checking the time
-remote m 		: Do the action on the remote machine m (name or IP)
-remschedule	: Do the scheduling on the remote machine
-use_nt 		: Use the NT protocol to shutdown/reboot a remote machine
-port p 		: Use port p to connect to the remote machine
-username u 	: User NT username u to connect to the remote machine
-password p 	: Use password p to connect to the remote machine
-run 		: Run a program before doing the action
-program "p" 	: Runs program p before doing the action
-directory "d" 	: Start the program in directory d
-notray 		: Do not show PowerBug icon in the system tray
-nocancel 		: Do not allow the user to cancel the action from the tray or in the warning dialog
-immediate 	: Perform the action immediately (default)
-scheduled 	: Perform the action in a scheduled manner
-time hh:mm 	: Perform the action at the specified time
-date dd/mm/yyyy	: Perform the action on the specified date
-days [m,t,...] 	: Perform the action on the specified days of the week (m,t,w,th,s,su)
-weeks [1,..,5]	: Perform the action on the specified weeks (default=all weeks)
-day d 		: Perform the action on the specified day of the month (1-31)
-seconds n 	: Perform the action after n seconds
-process p 	: Perform the action when a process named p does not exist anymore
-ip ip 		: Specifies the IP adress for WOL
-subnet s 		: Specifies the subnet mask for WOL
-mac m 		: Specifies the MAC address for WOL
-allow_remote 	: Allow remote control
-remote_port p 	: Listen on port p for commands
-remote_pswd p 	: Set a password that clients must give for remote control
-simulate 		: Simulate all actions, do not perform them
-minimize 		: Start minimized in the system tray
-quiet 		: Don't display error messages
-save_settings 	: Saves current settings to the registry
-remove_settings	: Remove the settings from the registry
-save_svc_set 	: Save current settings to the service
-remove_svc_set	: Removes the service settings
-create_service 	: Creates the PowerBug service, including the settings
-remove_service 	: Removes the PowerBug service, including the settings


The following command shuts down the PC after giving a 20 second warning.

C:\Program Files\TempElert\PowerBug.exe shutdown -warn -warntime 20 -msg "You will be logged off in 20 seconds"

The following command creates a service that shuts down the PC everyday at 23:00, forces all applications to close, gives a warning to the user, plays a sound file when the warning dialog is shown and listens for remote control using a password:

C:\Program Files\TempElert\PowerBug.exe shutdown -warn -warntime 60 -msg "You PC will PowerBug in 60 seconds\nPlease save your work" -playsound -soundfile "d:\winnt\media\ringin.wav" -force -scheduled -time 23:00 -days m,t,w,th,f,s,su -allow_remote -remote_pswd password -create_service

The following command will shutdown a remote computer using the standard NT protocol:

C:\Program Files\TempElert\PowerBug.exe shutdown -remote computer -use_nt -username computer\administrator -password password

The following command will reboot the computer after a program (cmd.exe) has finished:

C:\Program Files\TempElert\PowerBug.exe reboot –process cmd.exe

The following command will wake up a remote computer:

C:\Program Files\TempElert\PowerBug.exe wol –ip –subnet –mac 0050BF0852A2

The following command will log off the user 60 minutes after logging on when the command is put inside the startup folder. The user will not be able to see that PowerBug is running and will not be able to cancel it:

C:\Program Files\TempElert\PowerBug.exe logoff –scheduled –seconds 3600 –notray –nocancel –force

This command simply powers off your computer:

C:\Program Files\TempElert\PowerBug.exe PowerBug


Back to the Topic Menu

5.0 Remote Control Via TELNET

You can remotely control PowerBug by starting it as a service and setting the ‘Allow remote control’ option. You can control it by using PowerBug itself and selecting a remote computer, or you can control it by using telnet to the port where PowerBug listens to (default 3210).

For example TELNET [computername] 3210. You’ll see a welcome message like this:

201 Welcome to PowerBug 3.0

PowerBug uses a protocol like FTP or SMTP with commands and reply codes. You enter a command and PowerBug will reply with ‘2xx message’ on success or ‘5xx message’ on error.

You can enter the following commands:

QUIT 		Terminates the connection
HELP 		Shows this help
PASSWORD p 	Authenticates the client with a password
ACTION a 	The action to perform (logoff, reboot, shutdown, PowerBug, standby, hibernate, lock, wol)
WHO w 		Who must perform the action (local, remote)
WHEN w 		When must the action be performed (immediate, scheduled, after_process)
SIMULATE s 	Simulate the action (on, off)
COMPUTER c 	The remote computer name
MAC m 		The remote computer mac address (WOL)
IP i 		The remote computer ip address (WOL)
SUBNET s 	The remote computer subnet mask (WOL)
WARNING w 	Show warning before doing the action (on, off)
WARNTIME w 	The number of seconds to show the warning
MESSAGE m 	The warning message
PLAYSOUND p 	Play a sound when showing the warning (on, off)
SOUNDFILE s 	The WAV file to play
RUNPRG r 	Runs a program before doing the action (on, off)
PROGRAM p 	The program to run
DIRECTORY d 	The startup directory for the program
SCHEDULE s 	The type of schedule (fixed_day, daily, day_of_month, after_x_seconds)
TIME t 		The time when to do the action (hh:mm)
DATE d 		The date when to do the action (dd/mm/yyyy)
DAYS d 		The days of the week when to do the action (m, t, w, th, f, s, su)
WEEKS d 	The weeks of the month when to do the action (1, 2, 3, 4, 5)
DAY d 		The day of the month when to do the action (1-31)
WAIT w 		The number of seconds to wait before checking the time
SECONDS w 	The number of seconds to wait before doing the action
PROCESS p 	Wait for process p to finish
FORCE f 	Force applications to close (on, off)
CANCEL c 	Allow the user to cancel the action (on, off)
SHOW 		Show current settings
VERSION 	Show current PowerBug version
DOIT 		Do the action
STOP		Stops the current scheduled action

telnet [computername] 3210

201 Welcome to PowerBug 3.0
action logoff
250 OK
warning on
250 OK
message You will be logged off in 10 seconds
250 OK
warntime 10
250 OK
250 OK
201 Bye bye
Connection closed by foreign host.
Back to the Topic Menu

6.0 System Tray Operation

When PowerBug is minimized or it has a scheduled action, it sits in the system tray. You can right click the icon, then a popup menu appears:

Figure 13

Back to the Topic Menu

Updated 2/14/2003 by Anthony Watts