Question
ABeam Consulting Ltd.
JP
Last activity: 16 May 2019 12:38 EDT
Issue while starting Command Prompt
Hi Team,
I got the attached error while using text adapter to execute command in CMD.exe.
The error occurs when automation executes Start method of the adapter although the CMD.exe is shown then.
Now StartOnProjectStart is set False and StartMethod is set Start.
Starting interrogation occurs same error.
Do you have any solution about this?
<Environment>
OS:Windows 10
Studio: Pega Robotic Automation Studio 8.0 SP1 (8.0.2026)
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems Inc.
US
I am not sure I have ever seen the command prompt automated. Perhaps there is an easier way to do what you need though. What are you trying to accomplish?
ABeam Consulting Ltd.
JP
Hi Thomas,
Thank you for your reply.
I'm trying to create a reusable function to execute command on CMD.exe.
This is because sometimes I want to automate the processes via the command line inferface such as launching application and killing process.
Of course I should use adapter when I use applications but command line can be used when the target application cannot be interrogated correctly.
Do you have any solution to execute command via the commnad line instead of using text adapter?
Pegasystems Inc.
US
If you are executing single command or running a bat file, you can use the static method "Start" from System.Diagnostics.Process. To add this to an automation;
1. Right-click the Toolbox and select "Choose Items".
2. Select the "Pega Robotics Static Members" tab from the "Choose Toolbox Items" window.
3. Select the "From Global Assembly Cache" radio button.
4. Select the "System" assembly.
5. Locate the "Process" node and check the "Start" method.
6. Click "OK", and the method will get added to the Toolbox and can be added to an automation.
ABeam Consulting Ltd.
JP
Hi Thomas,
Thank you for a polite reply.
I believe we can use System.Diagnostics.Process.Start when the command key can be predefined and invariable.
But we cannot use it when we want to pass variables to command keys such as file path.
For example, "PDF Creator" has command line interface to convert a file into pdf format.
And its key is below,
pdfcreator.exe /PrintFile="C:\test.xlsx" /PrinterName="PDFCreator"
Of course we can create bat file to execute the command in advance, but the file path should be variable.
In this kind of situation, can we use System.Diagnostics.Process.Start?
Best regards,
Pegasystems Inc.
US
The method accepts a string. You can construct that string however you need to. I would use a stringUtils Format() method to build up the string to pass to the Start method. The FormatString would be something like;
pdfcreator.exe /PrintFile="{0}" /PrinterName="PDFCreator"
The second argument you pass to the Format method would be the path to the file.
ABeam Consulting Ltd.
JP
Thank you for your answer.
In this example, which one should we use in five methods of System.Process.Diagnostics.Start()?
I guess the third one which accepts "fileName" and "arguments" as its parameters.
Then the first parameter "fileName" should be "pdfcreator.exe" and the second parameter "arguments" should be "/PrintFile="C:\test.xlsx" /PrinterName="PDFCreator"".
Thank you and regards,
Pegasystems Inc.
US
Correct.