Overview

The configuration is defined in an XML file. Note: the XML configuration changed with Version 0.5 in favor of a more verifiable, element-based, configuration. These changes are reflected in the XSD.

<?xml version="1.0" encoding="utf-8"?>
<profiles>
   <profile name="main" default="true">
      <eventHandlers>

        <switchToBattery>
          <action type="KillProcess" processName="msseces.exe" />
          <KillProcess processName="msseces.exe" /> <!-- Same as above; preferred syntax -->
          <ControlService action="stop" serviceName="Windows Search" /> 
        </switchToBattery>

        <switchToAc>
          <StartProcess processName="msseces.exe" workingDirectory="C:\Program Files\Microsoft Security Essentials" />          
          <ControlService action="start" serviceName="Windows Search" />
        </switchToAc>

         <batteryPercentIncreased>
            <!-- Perform these action when the battery power increases by one percent -->
         </batteryPercentIncreased>

         <batteryPercentDecreased>
            <!-- Perform these action when the battery power decreases by one percent -->
         </batteryPercentDecreased>
      </eventHandlers>
   </profile>
</profiles>
</profiles>
You can download the XSD.

Elements

profiles/profile
A named configuration. Multiple profiles can exist.

profiles/profile/eventHandlers/switchToBattery
The actions to be performed when the power state switches to battery

profiles/profile/eventHandlers/switchToAc
The actions to be performed when the power state switches to AC

profiles/profile/eventHandlers/*/[action|ControlDevice|ControlServce|StartProces|KillProcess]
The action to execute. The type attribute or the element name corresponds to a class name that implements the IAction interface. The parameters vary based on the type.

Profiles

Multiple profiles can be defined in the configuration file. You can specify which profile to load by setting it as the default in the configuration file or by specifying the parameter on the command line BatterySaver.exe <profileName>. Additionally, you can switch between profiles by right-clicking on the context menu and choosing a different profile to load.

Actions

You can define what actions should be taken for power state events by configuring one or more <action> elements. The <action> element has a type attribute. The various types and their expected attributes are defined below.

Type: StartProcess

Attempts to start a process. If allowMultiple is specified and set to true then the process will be started even if another copy is already running.

Parameter name Required Values Default
processName yes the name of a process with extension N/A
workingDirectory yes directory path N/A
allowMultiple no [true|false] false

Type: KillProcess

Attempts to kill a running process

Parameters
Parameter name Required Values Default
processName yes the name of a process with extension N/A

Type: ControlService

Attempts to start or stop a service. Note: this action will silently fail if the service cannot be stopped or started

Parameters
Parameter name Required Values Default
action yes [start|stop] N/A
serviceName yes the friendly or system name for a service N/A

Type: Control Device

Attempts to enable or disable a device.

Parameters
Parameter name Required Values Default
action yes [enable|disable] enable
deviceClassId yes the device class GUID (from Device Manager) N/A
deviceInstanceId yes the device instance path (from Device Manager) N/A

To find the deviceClassId and deviceInstanceId see: Finding Device Details

Last edited Apr 2, 2010 at 2:04 PM by rdez6173, version 6

Comments

No comments yet.