Loading ...

Running scripts from powerchute syntax | UPS Management Devices & PowerChute Software

Home » Spaces » UPS Management Devices & PowerChute Software » discussion » General » Running scripts from powerchute syntax

Running scripts from powerchute syntax

Discussion in UPS Management Devices & PowerChute Software started by Rob , 17 days ago
Login to follow, share, and participate in this space.
Not a member?Join now
Announcement 

Please review Schneider Electric Knowledge Base articles for assistance with most technical support questions.  http://www.apc.com/us/en/faqs

Posted in: General

Running scripts from powerchute syntax

Subscribe to RSS
  • Hi

    Im trying to run this which runs fine form the command line:

    plink.exe -batch -ssh admin@192.168.1.1 -pw MyPassword -m "D:\Program Files (x86)\APC\PowerChute Business Edition\APC\PowerChute Business Edition\agent\cmdfiles\command.txt" > output.txt

    I have understand I need to put full paths and the apostrophes in front of the path and arguments outside so I end up with this which fails, can I have apostrophes around paths in the arguments?

    @START "" "D:\Program Files\PuTTY\plink.exe" -batch -ssh admin@192.168.1.30 -pw MyPassword -m "D:\Program Files (x86)\APC\PowerChute Business Edition\APC
    \PowerChute Business Edition\agent\cmdfiles\command.txt" > output.txt

    Any tips?

    Many thanks

  • Sorry I should have added my platform is Smart-UPS SMT-SmartConnect - SMT750IC 

    I running the script on Windows 2012 server, and the target to shutdown is a QNAP 451

    tx

     

  • Hi,

    PowerChute cannot execute programs that require interaction with the desktop; only command line enabled programs are supported e.g. if you try to launch Plink.exe it will fail. 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 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. More information on Windows Session can be found at http://blogs.technet.com/b/askperf/archive/2007/04/27/application-compatibility-session-0-isolation.aspx

    There is a work around. Anytime the PowerChute Agent records an event that event gets recorded to the Windows Event Viewer. You can schedule a task for an even and that task will trigger the .exe. 

    Here is a link to a video that demonstrates how to create an task for a PowerChute event.

    https://schneider-electric.box.com/s/6d0hpkq906r9l94sruibfg6c39mwzr2q

  • On 4/26/2021 9:57 PM, Bill said:

    Hi,

    PowerChute cannot execute programs that require interaction with the desktop; only command line enabled programs are supported e.g. if you try to launch Plink.exe it will fail. 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 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. More information on Windows Session can be found at http://blogs.technet.com/b/askperf/archive/2007/04/27/application-compatibility-session-0-isolation.aspx

    There is a work around. Anytime the PowerChute Agent records an event that event gets recorded to the Windows Event Viewer. You can schedule a task for an even and that task will trigger the .exe. 

    Here is a link to a video that demonstrates how to create an task for a PowerChute event.

    https://schneider-electric.box.com/s/6d0hpkq906r9l94sruibfg6c39mwzr2q

    Hi Bill

    Thanks very much for this, although Im slightly confused as I thought I got it working, as I could run plink from a batch file from the test your script section from the powerchute ui in shutdown settings.

    Does this mean that the testing of the script from the ui doesnt represent the same outcome if an actual powerchute event is handled?

    Many thanks

     

  • Also, Bill I couldnt ask.

    I want the UPS to shut down a windows server 2012 and a NAS, I have a serial cable and a usb. I havent read anywhere that you can do it, but can you connect the smart ups to two devices one via usb and one via serial

     

    Many thanks

     

  • Yes that is exactly what it means.

  • No unfortunately not, it's serial or USB, you'd need a NMC to shutdown multiple devices.

    -Gavan

  • Thanks for the confirmation

  • Hi,

    In each case PowerChute is executing the command file. As mentioned, PowerChute is running as a service and therefore runs in session zero. For security Microsoft separated services and application. When PowerChute calls the .cmd it runs however the .exe does not. The solution is to use task manager. If you were running a command line action you would not need the task manager.

    Example: echo %time% >> C:\Temp\cmdtest.txt 

    Another example: shutdown /s /f /m \\server ip /c "PowerChute has initiated a system shutdown" /t 0 to shut down a remote Windows OS. 

    As for multiple systems connected using USB and Serial, as Gavan wrote, it is not recommended to use Serial and USB.

    One notes, if one system runs shutdown, only software, i.e., not communicating with the UPS to configure the UPS, and one is running PowerChute; then you can connect two units utilizing both Serial and USB comm. 

    An example: I have an Iomega NAS connected to Smart-UPS SMT1500 via USB. The Iomega only listens to the UPS; it does not send commands to the UPS (AKA Simple Signalling). On the Serial port, I have a Linux server connected running PowerChute. PowerChute is configured in Smart Signalling mode, so the communication is two ways. This configuration is acceptable as the PowerChute Server is the only device sending commands to the UPS.

  • Thanks Bill, 

    Really interesting, youre a font of knowledge on this.


    So I have got this working now and thanks for your help but I am left foxed:

    So I created a task on Win 2012 r2. that was listening for event 3000, lost communication

    I had created a command file with the following contents that Powerchute would run, on my QNAP451 , on the on battery event of the Smart UPS

    @START "" "D:\Program Files\PuTTY\plink.exe" -batch -ssh admin@192.168.1.1 -pw Password poweroff

    I tested that powerchute could run this from the system settings ui

    To find out the correct eventid , I took the power out from the ups to simulate the on battery event.

    When I did this, the QNAP powered down gracefully, I checked the task history of the win 2012 task and it hadnt run, so it would seem the cmd file runs.

    Is what you are saying that powerchute can run command line apps, but not exes with a ui.

    It also seems that you can embed plink which doesnt have a ui in a batch file  and it can be run by powerchute


    Best

     

     

     

     

     

     

  • Rob,

    I did more testing and found that when I change the PowerChute service account to an admin account the .exe would run.

    When leaving the service at the default local system account the .exe would not run. I had to use the task manager to launch the .exe. 

  • Thanks for your work\thoughts Bill. Good to find that out

Page 1 of 1 (12 items)
Choose your language:  
powered by Communifire
Version 8.0.7757.16597