Question
Incessant Technologies
IN
Last activity: 26 Sep 2017 1:59 EDT
Calling batch file or script from automation
Hi,
Can any one know how to call a batch file or script from robotics automation?
***Updated by moderator: Lochan to add Categories***
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Pegasystems Inc.
AU
Hi Sreedhar,
I am not clear about how you have tried to invoke the activity. But the solution that I have given earlier will work. I strongly recommend you to use the c# scripting within the robotics studio, instead of writing the scripts externally and calling them from the robotics framework.
Pega robotics is tightly integrated with the .net framework and you can achieve almost all the functionalities that you perform using the external executable files.
However, just to answer your question about how to achieve the functionality to call the external executable, I have created the script for you. Please see the screenshots attached.
Screen shot 1: Automation flow [Invoked the script using the button click event, you can use any other event to trigger the script]
Screen shot 2: Actual script to invoke the external batch file [Make sure you are passing the reference in the reference section. Also click validate button to check that you do not see any errors in the script]
Screen Shot 3: Code of the external batch file that I am invoking from automation
Screen Shot 4: Automation script executed succesfully
Screetshot 5: Folder got created by the external batch file.
Hi Sreedhar,
I am not clear about how you have tried to invoke the activity. But the solution that I have given earlier will work. I strongly recommend you to use the c# scripting within the robotics studio, instead of writing the scripts externally and calling them from the robotics framework.
Pega robotics is tightly integrated with the .net framework and you can achieve almost all the functionalities that you perform using the external executable files.
However, just to answer your question about how to achieve the functionality to call the external executable, I have created the script for you. Please see the screenshots attached.
Screen shot 1: Automation flow [Invoked the script using the button click event, you can use any other event to trigger the script]
Screen shot 2: Actual script to invoke the external batch file [Make sure you are passing the reference in the reference section. Also click validate button to check that you do not see any errors in the script]
Screen Shot 3: Code of the external batch file that I am invoking from automation
Screen Shot 4: Automation script executed succesfully
Screetshot 5: Folder got created by the external batch file.
I have included the sample project for your reference "Batch File Execution Automation.txt " . Please rename the extension to .Zip to view the actual script
Please let me know if this helped.
Thanks,
Sudheer
Pegasystems Inc.
AU
Hi Sreedhar,
By default PegaRobotics supports all .Net libraries. You can include the following c# code in the script component [Place the script component in the Global Container] to call a bacth file [Included the screenshot for your reference]. Hope this answered your question.
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = "C:\\Watcher\\Cleanup.bat";
proc.Start
Regards,
Sudheer
-
Kunihiko Harada
Incessant Technologies
IN
Hi Sudheer,
Thanks for your reply. I am able to add the script file. I just added very simple script which create a directory. I am not able to see any output after executing this automation. I am not sure is it calling the script and is it failing somewhere. If I am missing something can you please
Content in script file is - md demo
Incessant Technologies
IN
*** Correcting the full sentence.****
Hi Sudheer,
Thanks for your reply. I am able to add the script file. I just added very simple script which create a directory. I am not able to see any output after executing this automation. I am not sure is it calling the script and is it failing somewhere. If I am missing something can you please help to resolve the issue.
Content in script file is - md demo
Accepted Solution
Pegasystems Inc.
AU
Hi Sreedhar,
I am not clear about how you have tried to invoke the activity. But the solution that I have given earlier will work. I strongly recommend you to use the c# scripting within the robotics studio, instead of writing the scripts externally and calling them from the robotics framework.
Pega robotics is tightly integrated with the .net framework and you can achieve almost all the functionalities that you perform using the external executable files.
However, just to answer your question about how to achieve the functionality to call the external executable, I have created the script for you. Please see the screenshots attached.
Screen shot 1: Automation flow [Invoked the script using the button click event, you can use any other event to trigger the script]
Screen shot 2: Actual script to invoke the external batch file [Make sure you are passing the reference in the reference section. Also click validate button to check that you do not see any errors in the script]
Screen Shot 3: Code of the external batch file that I am invoking from automation
Screen Shot 4: Automation script executed succesfully
Screetshot 5: Folder got created by the external batch file.
Hi Sreedhar,
I am not clear about how you have tried to invoke the activity. But the solution that I have given earlier will work. I strongly recommend you to use the c# scripting within the robotics studio, instead of writing the scripts externally and calling them from the robotics framework.
Pega robotics is tightly integrated with the .net framework and you can achieve almost all the functionalities that you perform using the external executable files.
However, just to answer your question about how to achieve the functionality to call the external executable, I have created the script for you. Please see the screenshots attached.
Screen shot 1: Automation flow [Invoked the script using the button click event, you can use any other event to trigger the script]
Screen shot 2: Actual script to invoke the external batch file [Make sure you are passing the reference in the reference section. Also click validate button to check that you do not see any errors in the script]
Screen Shot 3: Code of the external batch file that I am invoking from automation
Screen Shot 4: Automation script executed succesfully
Screetshot 5: Folder got created by the external batch file.
I have included the sample project for your reference "Batch File Execution Automation.txt " . Please rename the extension to .Zip to view the actual script
Please let me know if this helped.
Thanks,
Sudheer
-
Kapil Garg
Incessant Technologies
IN
Thanks a lot Sudheer for detailed information with sample project. Really its helps me a lot. It is working fine for me now.
Regards,
Sreedhar K
Incessant Technologies
IN
Hi Sudheer,
One more small query. Can we pass params to batch file. When i am trying to pass params its not triggering the batch file. Below is sample example.
C:\\scripts\\utils\\Utils.bat export
If I give like this in script automation its not working. Is is possible to pass params or can we call only batch file directly.
Regards,
Sreedhar K
Pegasystems Inc.
US
The Process.Start method has an overload that accepts arguments as a parameter. You can update the script above, or use the method Jeff shows below to call this version of the Start method.
https://msdn.microsoft.com/en-us/library/h6ak8zt5(v=vs.110).aspx
Pegasystems Inc.
US
You should also avoid using scripts when not necessary. To do your make directory - you would have to add to the toolbox a couple of static methods from the Pega Robotics Static Methods tab.
Then add this to your automation:
Incessant Technologies
IN
Hi Jeff,
Thank you very much for more helpful information about the existing methods. Can you please help us where we can get any documentation or help about existing methods/OOTB functions information. For us its new and we may not know which library is useful for which functionality.
Regards,
Sreedhar K
Pegasystems Inc.
US
What Jeff showed were static .Net methods available to any .Net project. Those can be found on MSDN. As for Pega Robotics (OpenSpan) specific documentation, aside from PDN, you should go to help.openspan.com. It contains a fairly comprehensive inventory of our components and various examples you might use.
infineon technologies banglore
IN
Hello,
Am new to this forum . As i came across the batchmode script in this discussion , i would like to discuss my problem.
am working on tool Altium which should be automated in batch command mode. i have a delphi(.pas) script in altium which i want to invoke it through batchmode command.
can i get a command to invoke the script from tool and command to export the script into other tools
Regards,
Sushmitha
Updated: 20 Sep 2017 9:33 EDT
Pegasystems Inc.
IN
Hi Sushmitha,
To get your query better visibility, we hace branched your reply into a new post. Please continue troubleshooting over the new post: Can I get a command to invoke the script from tool and command to export the script into other tools
Regards,
infineon technologies banglore
IN
Hello,