01 March 2021
How to configure command files / scripts for use with PowerChute Business Edition
PowerChute Business Edition
All support Windows OS
Please follow these steps to properly configure the command file / script option within PowerChute Business Edition :
1. Create the .cmd or .bat file and insert it into the cmdfile folder of PowerChute Business Edition. The @START must be used if the command file is calling an executable file AKA .exe (see NOTE below). The syntax should look like the following example (using the proper directory and executable names of course):
@START "" "C:\testdir\ myfile.exe"
There have also been instances where multiple line command files do not properly execute. In this configuration, a single line command file should be used to call the subsequent multiple line command file.
NOTE: In earlier versions of Windows all services run in Session 0 along with applications. This situation poses a security risk. In Windows Vista, and later versions of Windows, the operating system isolates services in Session 0 and runs applications in other sessions. PowerChute Business Edition Agent is run in Session 0 so if a command file launches a .exe that .exe will be launched in Session 0 and not visible to the logged in users. To verify that the .exe has launched open Task Manager and review the list of Processes running. More information on Windows Session can be found at https://blogs.technet.com/b/askperf/archive/2007/04/27/application-compatibility-session-0-isolation.aspx
2. Set up configure shutdown and choose the command file from the dropdown list and hit the test button (if running PCBE version 7.04 or Agent version 9.1 and above). Events can also be configured to run from the web UI on the agent directly. This may not work properly if the agent is controlled by PCBE server and the web UI. We do not recommend used in the web UI and the server to configure the Agent/s version 9.0.2 and below.
3. If the test fails, go to Services and right click on the Agent service and choose Properties.
4. Click on the "Log On" tab.
5. Check the box for "Interact with Desktop". If the command file is executing commands to another computer, the local system account that the service runs as does not have the proper rights. In this case, the service should be set to log in as a user that does have rights on the secondary system. Please keep in mind also that passwords for the logged in account will not automatically change when the user's password changes for his account. The log in as account should be a user with a password that does not expire.
6. Stop the Agent service and restart it. Retest the command file through PowerChute.
7. If the command file is still not running, try a simple command file for a test. Create a directory directly on the C drive and for this test and call it apctest. The following single line in a command file will create a a file in the apctest named cmdtest.txt and the time that the file was run should be in the file:
time /T >> C:\apctest\cmdtest.txt