Close popover
Kensho Tsuchihashi (KenshoTsuchihashi)
Project Delivery Leader
Pegasystems Inc.
KenshoTsuchihashi Member since 2010 137 posts
Posted: September 18, 2020
Last activity: 2 days 6 hours ago

How to call OS command from an activity


In the past, I shared how to call an activity from batch file (https://collaborate.pega.com/discussion/how-call-activity-batch-file). In this post I am sharing the opposite - how to call batch file from an activity. Batch (Windows), Shell (UNIX), or any OS command can be run using this approach.

In standard Java, Runtime.getRuntime() or new ProcessBuilder are available for use to call OS command. Until Pega 8.2, things were simple - we could write these in the activity directly. However, unfortunately starting with 8.3, these were banned to use in PRPC for security reasons (Java injection vulnerabilities). Prohibited code includes:

  • Runtime.getRuntime()
  • new ProcessBuilder()
  • JavaCompiler
  • org.dita.dost.invoker

If you try it, PRPC throws an error both in design time and run time. For example, below code is to run calculator program on Windows and it was valid in 8.2. From 8.3 onwards, it won't even let you save the rule.

Java Injection

However, sometimes customer may still require such implementation per their business needs. Workaround is to to write a Java code outside of PRPC, package it to Java Archive (Jar), import it into Pega database, and call it from an activity. This way, you can still achieve the same.



  1. Using Java IDE, write a Java program and compile it to make class files. Then package them up into a single Jar file.
  2. From Dev Studio, using the regular Import tool, import the Jar file into Pega database. It goes to PR_ENGINECLASSES table in the rules schema.
  3. Restart the application server so that your custom class in Jar gets loaded in the bootstrap process.
  4. Create an activity and call its method.

I have documented How-to as attached. Hope this helps.




Pega Platform 8.4.1 Developer Knowledge Share